Class: Matchi::Be
- Inherits:
-
Object
- Object
- Matchi::Be
- Defined in:
- lib/matchi/be.rb
Overview
Identity matcher.
Instance Method Summary collapse
-
#initialize(expected) ⇒ Be
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) ⇒ Be
Initialize the matcher with an object.
14 15 16 |
# File 'lib/matchi/be.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/be.rb', line 30 def match? raise ::ArgumentError, "a block must be provided" unless block_given? @expected.equal?(yield) end |
#to_s ⇒ String
Returns a string representing the matcher.
39 40 41 |
# File 'lib/matchi/be.rb', line 39 def to_s "be #{@expected.inspect}" end |