Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Save failed features from #run_all #13

Merged
merged 1 commit into from
Jul 4, 2011
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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