Class: Matchi::RaiseException
- Inherits:
-
Object
- Object
- Matchi::RaiseException
- Defined in:
- lib/matchi/raise_exception.rb
Overview
*Expecting errors* matcher.
Instance Attribute Summary collapse
-
#expected ⇒ String
readonly
The expected exception name.
Instance Method Summary collapse
-
#initialize(expected) ⇒ RaiseException
constructor
Initialize the matcher with a descendant of class Exception.
-
#inspect ⇒ Object
A string containing a human-readable representation of the matcher.
-
#matches? ⇒ Boolean
Boolean comparison between the actual value and the expected value.
-
#to_s ⇒ Object
Returns a string representing the matcher.
Constructor Details
#initialize(expected) ⇒ RaiseException
Initialize the matcher with a descendant of class Exception.
17 18 19 |
# File 'lib/matchi/raise_exception.rb', line 17 def initialize(expected) @expected = String(expected) end |
Instance Attribute Details
#expected ⇒ String (readonly)
Returns The expected exception name.
7 8 9 |
# File 'lib/matchi/raise_exception.rb', line 7 def expected @expected end |
Instance Method Details
#inspect ⇒ Object
A string containing a human-readable representation of the matcher.
44 45 46 |
# File 'lib/matchi/raise_exception.rb', line 44 def inspect "#{self.class}(#{expected})" end |
#matches? ⇒ Boolean
Boolean comparison between the actual value and the expected value.
35 36 37 38 39 40 41 |
# File 'lib/matchi/raise_exception.rb', line 35 def matches? yield rescue self.class.const_get(expected) => _e true else false end |
#to_s ⇒ Object
Returns a string representing the matcher.
49 50 51 |
# File 'lib/matchi/raise_exception.rb', line 49 def to_s "raise exception #{expected}" end |