Sha256: efcb916c2ca4b13d3a39af2b6753929edd7ab49f16bdc970e3a538c936fe9a53
Contents?: true
Size: 811 Bytes
Versions: 4
Compression:
Stored size: 811 Bytes
Contents
module Matchi # **Expecting errors** matcher. class RaiseException < BasicObject # Initialize the matcher with a descendant of class Exception. # # @example Divided by 0 matcher # Matchi::RaiseException.new(ZeroDivisionError) # # @param expected [.exception] The class of the expected exception. def initialize(expected) @expected = expected end # @example Is it raising NameError? # raise_exception = Matchi::RaiseException.new(NameError) # raise_exception.matches? { Boom } # => true # # @yieldreturn [#object_id] the actual value to compare to the expected one. # # @return [Boolean] Comparison between actual and expected values. def matches? yield rescue @expected true else false end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
matchi-0.0.9 | lib/matchi/raise_exception.rb |
matchi-0.0.8 | lib/matchi/raise_exception.rb |
matchi-0.0.7 | lib/matchi/raise_exception.rb |
matchi-0.0.6 | lib/matchi/raise_exception.rb |