Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into prevent_cucumber_ym…
Browse files Browse the repository at this point in the history
…l_being_read_twice

Conflicts:
	lib/cucumber/cli/options.rb
  • Loading branch information
tooky committed Apr 5, 2013
2 parents d62ba6a + 24496a2 commit 897c32a
Show file tree
Hide file tree
Showing 11 changed files with 569 additions and 83 deletions.
128 changes: 77 additions & 51 deletions features/.cucumber/stepdefs.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,15 @@
"flags": "",
"file_colon_line": "aruba-0.5.1/lib/aruba/cucumber.rb:19",
"steps": [

{
"name": "a file named \"cucumber.yml\" with:",
"args": [
{
"offset": 14,
"val": "cucumber.yml"
}
]
}
]
},
{
Expand Down Expand Up @@ -108,24 +116,7 @@
"flags": "",
"file_colon_line": "aruba-0.5.1/lib/aruba/cucumber.rb:60",
"steps": [
{
"name": "I run `bundle exec rake fail`",
"args": [
{
"offset": 7,
"val": "bundle exec rake fail"
}
]
},
{
"name": "I run `bundle exec rake pass`",
"args": [
{
"offset": 7,
"val": "bundle exec rake pass"
}
]
}

]
},
{
Expand Down Expand Up @@ -205,31 +196,33 @@
"flags": "",
"file_colon_line": "aruba-0.5.1/lib/aruba/cucumber.rb:109",
"steps": [
{
"name": "the output should not contain \"rake aborted!\"",
"args": [
{
"offset": 31,
"val": "rake aborted!"
}
]
}

]
},
{
"source": "^the output should contain:$",
"flags": "",
"file_colon_line": "aruba-0.5.1/lib/aruba/cucumber.rb:113",
"steps": [
{
"name": "the output should contain:",
"args": [

]
}
]
},
{
"source": "^the output should not contain:$",
"flags": "",
"file_colon_line": "aruba-0.5.1/lib/aruba/cucumber.rb:117",
"steps": [
{
"name": "the output should not contain:",
"args": [

]
}
]
},
{
Expand All @@ -249,7 +242,7 @@
]
},
{
"source": "^the output should match \\/([^\\/]*)\\/$",
"source": "^the output should match /([^/]*)/$",
"flags": "",
"file_colon_line": "aruba-0.5.1/lib/aruba/cucumber.rb:137",
"steps": [
Expand All @@ -265,7 +258,7 @@
]
},
{
"source": "^the output should not match \\/([^\\/]*)\\/$",
"source": "^the output should not match /([^/]*)/$",
"flags": "",
"file_colon_line": "aruba-0.5.1/lib/aruba/cucumber.rb:146",
"steps": [
Expand All @@ -285,31 +278,15 @@
"flags": "",
"file_colon_line": "aruba-0.5.1/lib/aruba/cucumber.rb:154",
"steps": [
{
"name": "the exit status should be 0",
"args": [
{
"offset": 26,
"val": "0"
}
]
}

]
},
{
"source": "^the exit status should not be (\\d+)$",
"flags": "",
"file_colon_line": "aruba-0.5.1/lib/aruba/cucumber.rb:158",
"steps": [
{
"name": "the exit status should not be 0",
"args": [
{
"offset": 30,
"val": "0"
}
]
}

]
},
{
Expand Down Expand Up @@ -537,15 +514,15 @@
]
},
{
"source": "^the file \"([^\"]*)\" should match \\/([^\\/]*)\\/$",
"source": "^the file \"([^\"]*)\" should match /([^/]*)/$",
"flags": "",
"file_colon_line": "aruba-0.5.1/lib/aruba/cucumber.rb:308",
"steps": [

]
},
{
"source": "^the file \"([^\"]*)\" should not match \\/([^\\/]*)\\/$",
"source": "^the file \"([^\"]*)\" should not match /([^/]*)/$",
"flags": "",
"file_colon_line": "aruba-0.5.1/lib/aruba/cucumber.rb:312",
"steps": [
Expand All @@ -557,15 +534,64 @@
"flags": "",
"file_colon_line": "features/step_definitions/cucumber_steps.rb:1",
"steps": [

{
"name": "I run cucumber \"--profile default --format html\"",
"args": [
{
"offset": 16,
"val": "--profile default --format html"
}
]
},
{
"name": "I run cucumber \"--profile default --format pretty\"",
"args": [
{
"offset": 16,
"val": "--profile default --format pretty"
}
]
},
{
"name": "I run cucumber \"--profile default --format progress\"",
"args": [
{
"offset": 16,
"val": "--profile default --format progress"
}
]
},
{
"name": "I run cucumber \"features/scenario_outline_with_undefined_steps.feature --format pretty --expand \"",
"args": [
{
"offset": 16,
"val": "features/scenario_outline_with_undefined_steps.feature --format pretty --expand "
}
]
},
{
"name": "I run cucumber \"features/scenario_outline_with_undefined_steps.feature --format progress --expand \"",
"args": [
{
"offset": 16,
"val": "features/scenario_outline_with_undefined_steps.feature --format progress --expand "
}
]
}
]
},
{
"source": "^it\\ should\\ pass$",
"flags": "",
"file_colon_line": "features/step_definitions/cucumber_steps.rb:5",
"steps": [
{
"name": "it should pass",
"args": [

]
}
]
},
{
Expand Down
12 changes: 12 additions & 0 deletions features/html_formatter.feature
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,15 @@ Feature: HTML output formatter
When I run cucumber "features/scenario_outline_with_undefined_steps.feature --format html --expand "
Then it should pass

Scenario: when using a profile the html shouldn't include 'Using the default profile...'
And a file named "cucumber.yml" with:
"""
default: -r features
"""
When I run cucumber "--profile default --format html"
Then it should pass
And the output should not contain:
"""
Using the default profile...
"""

31 changes: 31 additions & 0 deletions features/pretty_formatter.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
Feature: Pretty output formatter

Background:
Given a file named "features/scenario_outline_with_undefined_steps.feature" with:
"""
Feature:
Scenario Outline:
Given an undefined step
Examples:
|foo|
|bar|
"""

Scenario: an scenario outline, one undefined step, one random example, expand flag on
When I run cucumber "features/scenario_outline_with_undefined_steps.feature --format pretty --expand "
Then it should pass

Scenario: when using a profile the output should include 'Using the default profile...'
And a file named "cucumber.yml" with:
"""
default: -r features
"""
When I run cucumber "--profile default --format pretty"
Then it should pass
And the output should contain:
"""
Using the default profile...
"""

31 changes: 31 additions & 0 deletions features/progress_formatter.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
Feature: Progress output formatter

Background:
Given a file named "features/scenario_outline_with_undefined_steps.feature" with:
"""
Feature:
Scenario Outline:
Given an undefined step
Examples:
|foo|
|bar|
"""

Scenario: an scenario outline, one undefined step, one random example, expand flag on
When I run cucumber "features/scenario_outline_with_undefined_steps.feature --format progress --expand "
Then it should pass

Scenario: when using a profile the output should include 'Using the default profile...'
And a file named "cucumber.yml" with:
"""
default: -r features
"""
When I run cucumber "--profile default --format progress"
Then it should pass
And the output should contain:
"""
Using the default profile...
"""

16 changes: 4 additions & 12 deletions lib/cucumber/cli/options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ def initialize(out_stream = STDOUT, error_stream = STDERR, options = {})
@error_stream = error_stream

@default_profile = options[:default_profile]
@skip_profile_information = options[:skip_profile_information]
@profiles = []
@overridden_paths = []
@options = default_options
@profile_loader = options[:profile_loader]
@options[:skip_profile_information] = options[:skip_profile_information]

@quiet = @disable_profile_loading = nil
end
Expand Down Expand Up @@ -241,7 +241,7 @@ def parse!(args)
opts.on("-i", "--no-snippets", "Don't print snippets for pending steps.") do
@options[:snippets] = false
end
opts.on("-I", "--snippet-type TYPE",
opts.on("-I", "--snippet-type TYPE",
"Use different snippet type (Default: regexp). Available types:",
*Cucumber::RbSupport::RbLanguage.cli_snippet_type_options) do |v|
@options[:snippet_type] = v.to_sym
Expand Down Expand Up @@ -302,7 +302,6 @@ def parse!(args)
@options[:paths] = @args.dup #whatver is left over

merge_profiles
print_profile_information

self
end
Expand Down Expand Up @@ -354,6 +353,8 @@ def merge_profiles
@profiles.each do |profile|
merge_with_profile(profile)
end

@options[:profiles] = @profiles
end

def merge_with_profile(profile)
Expand Down Expand Up @@ -418,15 +419,6 @@ def list_languages_and_exit
Kernel.exit(0)
end

def print_profile_information
return if @skip_profile_information || @profiles.empty?
profiles_sentence = ''
profiles_sentence = @profiles.size == 1 ? @profiles.first :
"#{@profiles[0...-1].join(', ')} and #{@profiles.last}"

@out_stream.puts "Using the #{profiles_sentence} profile#{'s' if @profiles.size> 1}..."
end

def default_options
{
:strict => false,
Expand Down
10 changes: 10 additions & 0 deletions lib/cucumber/formatter/console.rb
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,16 @@ def empty_messages
@delayed_messages = []
end

def print_profile_information
return if @options[:skip_profile_information] || @options[:profiles].nil? || @options[:profiles].empty?
profiles = @options[:profiles]
profiles_sentence = ''
profiles_sentence = profiles.size == 1 ? profiles.first :
"#{profiles[0...-1].join(', ')} and #{profiles.last}"

@io.puts "Using the #{profiles_sentence} profile#{'s' if profiles.size> 1}..."
end

private

FORMATS = Hash.new{ |hash, format| hash[format] = method(format).to_proc }
Expand Down
6 changes: 5 additions & 1 deletion lib/cucumber/formatter/pretty.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ def initialize(runtime, path_or_io, options)
@delayed_messages = []
end

def before_features(features)
print_profile_information
end

def after_features(features)
print_summary(features) unless @options[:autoformat]
end
Expand Down Expand Up @@ -154,7 +158,7 @@ def step_name(keyword, step_match, status, source_indent, background, file_colon
end

def doc_string(string)
return if @hide_this_step
return if @options[:no_multiline] || @hide_this_step
s = %{"""\n#{string}\n"""}.indent(@indent)
s = s.split("\n").map{|l| l =~ /^\s+$/ ? '' : l}.join("\n")
@io.puts(format_string(s, @current_step.status))
Expand Down
Loading

0 comments on commit 897c32a

Please sign in to comment.