Sha256: 6e7599f5cb38a5082e2126d700dcfb8070c2f064c15d227d3e8210207c096790
Contents?: true
Size: 660 Bytes
Versions: 15
Compression:
Stored size: 660 Bytes
Contents
module Matest class NoExceptionRaised < RuntimeError; end class UnexpectedExceptionRaised < RuntimeError; end end 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
Version data entries
15 entries across 15 versions & 1 rubygems