Skip to content

Commit

Permalink
Save failed features from #run_all
Browse files Browse the repository at this point in the history
  • Loading branch information
lmarburger committed Jul 1, 2011
1 parent c5a7b5d commit caf67be
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/guard/cucumber.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,12 @@ def start
def run_all
passed = Runner.run(['features'], options.merge({ :message => 'Running all features' }))

@failed_paths = [] if passed
if passed
@failed_paths = []
else
@failed_paths = read_failed_features if @options[:keep_failed]
end

@last_failed = !passed

passed
Expand Down
25 changes: 25 additions & 0 deletions spec/guard/cucumber_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,31 @@
Guard::Cucumber::Runner.should_receive(:run).with(['features/bar'], default_options).and_return(true)
subject.run_on_change(['features/bar'])
end

it 'should save failed features' do
Guard::Cucumber::Runner.should_receive(:run).with(['features'], default_options.merge(:message => 'Running all features')).and_return(false)
File.should_receive(:exist?).with('rerun.txt').and_return true
File.stub_chain(:open, :read).and_return 'features/foo'
File.should_receive(:delete).with('rerun.txt')
subject.run_all

Guard::Cucumber::Runner.should_receive(:run).with(['features/bar', 'features/foo'], default_options).and_return(true)
Guard::Cucumber::Runner.should_receive(:run).with(['features'], default_options.merge(:message => 'Running all features')).and_return(true)
subject.run_on_change(['features/bar'])
end

it 'should not save failed features if keep_failed is disabled' do
run_options = default_options.merge :keep_failed => false
subject = Guard::Cucumber.new([], :keep_failed => false)

Guard::Cucumber::Runner.should_receive(:run).with(['features'], run_options.merge(:message => 'Running all features')).and_return(false)
File.should_not_receive(:exist?).with('rerun.txt').and_return true
subject.run_all

Guard::Cucumber::Runner.should_receive(:run).with(['features/bar'], run_options).and_return(true)
Guard::Cucumber::Runner.should_receive(:run).with(['features'], run_options.merge(:message => 'Running all features')).and_return(true)
subject.run_on_change(['features/bar'])
end
end

describe '#reload' do
Expand Down

0 comments on commit caf67be

Please sign in to comment.