Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

allow re-raising exceptions

  • Loading branch information...
commit a56f184c84f1f243da40daeaaf07f4ba931e6384 1 parent 1abec15
@svenfuchs svenfuchs authored
View
1  lib/travis/support/exceptions/handling.rb
@@ -10,6 +10,7 @@ def rescues(name, options = {})
method.call(*args, &block)
rescue options[:from] || Exception => e
Exceptions.handle(e, options.slice(:backtrace))
+ raise if options[:raise] && Array(options[:raise]).include?(e.class)
end
end unless Travis.env == 'test'
end
View
19 spec/travis/exceptions/handling_spec.rb
@@ -3,6 +3,8 @@
describe Travis::Exceptions::Handling do
let(:klass) do
+ options = self.options
+
Class.new do
extend Travis::Exceptions::Handling
@@ -11,7 +13,7 @@
def outer
inner
end
- rescues :outer
+ rescues :outer, options
def inner # so there's something we can stub for raising
@called = true
@@ -24,10 +26,11 @@ def arity_3(foo, bar, baz)
end
end
- let(:object) { klass.new }
+ let(:options) { {} }
+ let(:object) { klass.new }
before do
- Travis.stubs(:env).returns "development"
+ Travis.stubs(:env).returns 'development'
end
it 'calls the original implementation' do
@@ -50,4 +53,14 @@ def arity_3(foo, bar, baz)
it 'works with methods that have an arity of 3' do
object.arity_3(1, 2, 3).should == [1, 2, 3]
end
+
+ describe '' do
+ let(:error) { Class.new(StandardError) }
+ let(:options) { { raise: error } }
+
+ it '' do
+ object.stubs(:inner).raises(error)
+ lambda { object.outer }.should raise_error(error)
+ end
+ end
end
Please sign in to comment.
Something went wrong with that request. Please try again.