Method: Kernel#expect
- Defined in:
- lib/brass/expect.rb
#expect(error_class) ⇒ Object
Executate a block asserting that a type of error will be raised.
Presently this is not part of brass by default, as whether it should be is under debate. So this file must be required separately:
require 'brass/expect'
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/brass/expect.rb', line 12 def expect(error_class) #:yield: begin yield assert(false, error_class, "#{error_class} expected but none thrown") rescue error_class assert(true) rescue Exception => err assert(false, error_class, "#{error_class} expected but #{err.class} was thrown") end end |