Skip to content

Commit

Permalink
Syntax errors now stop the specs from running
Browse files Browse the repository at this point in the history
Before it would log an error and keep on going anyway.
The Containment#protect block now throws the symbol that instructs guard
that there was an error and to stop testing.
  • Loading branch information
nilbus committed May 29, 2013
1 parent 97ca58c commit 56598bb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
8 changes: 3 additions & 5 deletions lib/guard/jruby-rspec/runner.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require 'rspec'
require 'guard/jruby-rspec/containment'
require 'guard/jruby-rspec/formatters/notification_rspec'

module Guard
Expand Down Expand Up @@ -44,13 +45,10 @@ def run(paths, options = {})
# end
else
orig_configuration = ::RSpec.configuration
begin
Containment.new.protect do
::RSpec::Core::Runner.run(rspec_arguments(paths, @options))
rescue SyntaxError => e
UI.error e.message
ensure
::RSpec.instance_variable_set(:@configuration, orig_configuration)
end
::RSpec.instance_variable_set(:@configuration, orig_configuration)
end
end

Expand Down
6 changes: 4 additions & 2 deletions spec/guard/jruby-rspec/runner_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@ class Guard::JRubyRSpec::Runner::UI; end
context 'when one of the source files is bad' do
it 'recovers from syntax errors in files by displaying the error' do
RSpec::Core::Runner.stub(:run).and_raise(SyntaxError.new('Bad Karma'))
Guard::JRubyRSpec::Runner::UI.should_receive(:error).with('Bad Karma')
subject.run(['spec/foo'])
Guard::UI.should_receive(:error).at_least(1).times
expect {
subject.run(['spec/foo'])
}.to throw_symbol(:task_has_failed)
end
end
end
Expand Down

0 comments on commit 56598bb

Please sign in to comment.