Skip to content

Commit

Permalink
Adding --no-snippets option to hide pending snippets when using prett…
Browse files Browse the repository at this point in the history
…y formatter
  • Loading branch information
Joseph Wilk committed Oct 31, 2008
1 parent c1304d7 commit 1c41e27
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 1 deletion.
1 change: 1 addition & 0 deletions History.txt
Expand Up @@ -23,6 +23,7 @@ in the inside string. If the triple quotes are indented 4 spaces, then the text
spaces removed too.

=== New features
* Added --no-snippets option to hide snippets for pending steps when using Pretty formatter (#69 Joseph Wilk)
* Added Autotest support - work in progress... (Peter Jaros)
* Added new --exclude option (Bryan Helkamp)
* Added new --scenario option (Peter Jaros)
Expand Down
4 changes: 4 additions & 0 deletions lib/cucumber/cli.rb
Expand Up @@ -33,6 +33,7 @@ def initialize
:lang => 'en',
:dry_run => false,
:source => true,
:snippets => true,
:formats => {},
:excludes => [],
:scenario_names => nil
Expand Down Expand Up @@ -101,6 +102,9 @@ def parse_options!(args)
opts.on("-n", "--no-source", "Don't show the file and line of the step definition with the steps.") do
@options[:source] = false
end
opts.on("-s", "--no-snippets", "Don't show the snippets for pending steps") do
@options[:snippets] = false
end
opts.on_tail("--version", "Show version") do
puts VERSION::STRING
exit
Expand Down
2 changes: 1 addition & 1 deletion lib/cucumber/formatters/pretty_formatter.rb
Expand Up @@ -158,7 +158,7 @@ def dump

@io.print reset

print_snippets
print_snippets if @options[:snippets]
end

def print_snippets
Expand Down
8 changes: 8 additions & 0 deletions spec/cucumber/cli_spec.rb
Expand Up @@ -25,6 +25,7 @@ def mock_broadcaster(stubs = {})
:dry_run => false,
:lang => 'en',
:source => true,
:snippets => true,
:excludes => [],
:scenario_names => nil
}
Expand All @@ -43,6 +44,7 @@ def mock_broadcaster(stubs = {})
:dry_run => false,
:lang => 'en',
:source => true,
:snippets => true,
:excludes => [],
:scenario_names => nil
}
Expand All @@ -55,6 +57,12 @@ def mock_broadcaster(stubs = {})
cli.options[:source].should be_false
end

it "should accept --no-snippets option" do
cli = CLI.new
cli.parse_options!(%w{--no-snippets})
cli.options[:snippets].should be_false
end

it "should accept --out option" do
cli = CLI.new
File.should_receive(:open).with('jalla.txt', 'w')
Expand Down
20 changes: 20 additions & 0 deletions spec/cucumber/formatters/pretty_formatter_spec.rb
Expand Up @@ -10,6 +10,9 @@ def mock_step(stubs={})
:format => 'formatted yes',
:name => 'example',
:error => nil,
:padding_length => 2,
:file => 'test',
:line => 1,
:row? => false}.merge(stubs))
end

Expand Down Expand Up @@ -78,6 +81,23 @@ def mock_proc
io.string.should =~ /\n\n Scenario: spacey/
end

{'should' => true, 'should not' => false}.each do |should_or_should_not, show_snippet|
describe "snippets option #{show_snippet}" do

it "#{should_or_should_not} show snippet for pending step" do
@io = StringIO.new
step_mother = mock('step_mother')
@formatter = PrettyFormatter.new @io, step_mother, :snippets => show_snippet

@formatter.step_pending(mock_step(:actual_keyword => 'Given', :name => 'pending step snippet'), nil, nil)
@formatter.dump

@io.string.send(should_or_should_not.gsub(' ','_').to_sym, include("Given /^pending step snippet$/ do"))
end

end
end

describe "show source option true" do

before(:each) do
Expand Down

0 comments on commit 1c41e27

Please sign in to comment.