Skip to content

Commit

Permalink
Merge pull request #106 from rizzatti/throws_on_failed_run
Browse files Browse the repository at this point in the history
Add support for guard halt_on_fail
  • Loading branch information
rymai committed May 1, 2014
2 parents bfd1780 + 86df4e1 commit 77ac21c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
10 changes: 8 additions & 2 deletions lib/guard/minitest.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ def reload
end

def run_all
runner.run_all
throw_on_failed_tests { runner.run_all }
end

def run_on_modifications(paths = [])
runner.run_on_modifications(paths)
throw_on_failed_tests { runner.run_on_modifications(paths) }
end

def run_on_additions(paths)
Expand All @@ -47,5 +47,11 @@ def run_on_removals(paths)
runner.run_on_removals(paths)
end

private

def throw_on_failed_tests
throw :task_has_failed unless yield
end

end
end
16 changes: 14 additions & 2 deletions spec/lib/guard/minitest_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@

describe 'run_on_modifications' do
it 'is run through runner' do
runner.any_instance.expects(:run_on_modifications)

runner.any_instance.expects(:run_on_modifications => true)
guard.run_on_modifications
end
end
Expand All @@ -68,4 +67,17 @@
end
end

describe 'halting and throwing on test failure' do
it 'throws on failed test run' do
stubbed_runner = stub
stubbed_runner.stubs(:run).returns(false)
stubbed_runner.expects(:run_all)
stubbed_runner.expects(:run_on_modifications)

guard.runner = stubbed_runner

proc { guard.run_all }.must_throw :task_has_failed
proc { guard.run_on_modifications }.must_throw :task_has_failed
end
end
end

0 comments on commit 77ac21c

Please sign in to comment.