Class: RCheck::Assertions::Raises
- Defined in:
- lib/rcheck/assertions.rb
Instance Attribute Summary
Attributes inherited from Abstract
Instance Method Summary collapse
-
#initialize(expected, msg = nil, &blk) ⇒ Raises
constructor
A new instance of Raises.
Methods inherited from Abstract
Constructor Details
#initialize(expected, msg = nil, &blk) ⇒ Raises
Returns a new instance of Raises.
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 |
# File 'lib/rcheck/assertions.rb', line 101 def initialize(expected, msg=nil, &blk) @expected = expected @expected_msg = msg @status = :fail begin blk.call rescue Exception => e @raised = e if @expected && e.is_a?(@expected) && (msg.nil? || e. == msg) @status = :pass end end @status = :pass if @expected.nil? and @raised.nil? @result = Result.new( status: @status, location: caller(3), introspection: @raised ? @raised.inspect : 'no errors', backtrace: @status == :fail ? @raised.backtrace : nil) end |