Skip to content

Commit

Permalink
Close rerun.txt file properly after reading the failed features (fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
netzpirat committed Oct 14, 2011
1 parent 2e5cdd5 commit 9b6966a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/guard/cucumber.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def read_failed_features
failed = []

if File.exist?('rerun.txt')
failed = File.open('rerun.txt').read.split(' ')
failed = File.open('rerun.txt') { |file| file.read.split(' ') }
File.delete('rerun.txt')
end

Expand Down
8 changes: 6 additions & 2 deletions spec/guard/cucumber_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,9 @@
it 'saves failed features' do
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 = mock('file')
file.should_receive(:read).and_return 'features/foo'
File.stub(:open).and_yield file
File.should_receive(:delete).with('rerun.txt')
expect { guard.run_all }.to throw_symbol :task_has_failed

Expand Down Expand Up @@ -203,7 +205,9 @@

context 'with a rerun.txt file' do
before do
File.stub_chain(:open, :read).and_return 'features/foo'
file = mock('file')
file.stub(:read).and_return 'features/foo'
File.stub(:open).and_yield file
end

it 'keeps failed spec and rerun later' do
Expand Down

0 comments on commit 9b6966a

Please sign in to comment.