Class: Matchi::Eq
- Inherits:
-
Object
- Object
- Matchi::Eq
- Defined in:
- lib/matchi/eq.rb
Overview
Equivalence matcher.
Instance Method Summary collapse
-
#initialize(expected) ⇒ Eq
constructor
Initialize the matcher with an object.
-
#match? ⇒ Boolean
Boolean comparison between the actual value and the expected value.
-
#to_s ⇒ String
Returns a string representing the matcher.
Constructor Details
#initialize(expected) ⇒ Eq
Initialize the matcher with an object.
14 15 16 |
# File 'lib/matchi/eq.rb', line 14 def initialize(expected) @expected = expected end |
Instance Method Details
#match? ⇒ Boolean
Boolean comparison between the actual value and the expected value.
30 31 32 33 34 |
# File 'lib/matchi/eq.rb', line 30 def match? raise ::ArgumentError, "a block must be provided" unless block_given? @expected.eql?(yield) end |
#to_s ⇒ String
Returns a string representing the matcher.
39 40 41 |
# File 'lib/matchi/eq.rb', line 39 def to_s "eq #{@expected.inspect}" end |