class Matchi::RaiseException
*Expecting errors* matcher.
Attributes
expected[R]
@return [String] The expected exception name.
Public Class Methods
new(expected)
click to toggle source
Initialize the matcher with a descendant of class Exception.
@example
require "matchi/raise_exception" Matchi::RaiseException.new(NameError)
@param expected [Exception, to_s
] The expected exception name.
# File lib/matchi/raise_exception.rb, line 17 def initialize(expected) @expected = String(expected) end
Public Instance Methods
inspect()
click to toggle source
A string containing a human-readable representation of the matcher.
# File lib/matchi/raise_exception.rb, line 44 def inspect "#{self.class}(#{expected})" end
matches?() { || ... }
click to toggle source
Boolean comparison between the actual value and the expected value.
@example
require "matchi/raise_exception" matcher = Matchi::RaiseException.new(NameError) matcher.expected # => "NameError" matcher.matches? { Boom } # => true
@yieldreturn [#object_id] The actual value to compare to the expected
one.
@return [Boolean] Comparison between actual and expected values.
# File lib/matchi/raise_exception.rb, line 35 def matches? yield rescue self.class.const_get(expected) => _e true else false end
to_s()
click to toggle source
Returns a string representing the matcher.
# File lib/matchi/raise_exception.rb, line 49 def to_s "raise exception #{expected}" end