Top Level Namespace
Defined Under Namespace
Modules: Matest Classes: ExampleBlock
Instance Method Summary collapse
- #capture_exception(exception_class = nil, &block) ⇒ Object
- #scope(description = nil, &block) ⇒ Object (also: #describe, #context, #group)
- #xscope(description = nil, &block) ⇒ Object (also: #xdescribe, #xcontext, #xgroup)
Instance Method Details
#capture_exception(exception_class = nil, &block) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/matest/capture_exception.rb', line 6 def capture_exception(exception_class=nil, &block) expected_exception = exception_class || BasicObject begin block.call if exception_class raise Matest::NoExceptionRaised.new("Expected '#{exception_class.inspect}' from the block, but none was raised.") else raise Matest::NoExceptionRaised.new("Expected an Exception from the block, but none was raised.") end false rescue Matest::NoExceptionRaised => e raise e rescue expected_exception => e e rescue BasicObject => e raise e end end |