Class: Matchi::Be
- Inherits:
-
Object
- Object
- Matchi::Be
- Defined in:
- lib/matchi/be.rb
Overview
Identity matcher: passes when the actual value is the very same object as
the expected one (equal?).
Instance Method Summary collapse
-
#initialize(expected) ⇒ Be
constructor
A new instance of Be.
- #match? ⇒ Boolean
- #to_s ⇒ String
Constructor Details
#initialize(expected) ⇒ Be
Returns a new instance of Be.
12 13 14 |
# File 'lib/matchi/be.rb', line 12 def initialize(expected) @expected = expected end |
Instance Method Details
#match? ⇒ Boolean
19 20 21 22 23 |
# File 'lib/matchi/be.rb', line 19 def match? raise ::ArgumentError, "a block must be provided" unless block_given? @expected.equal?(yield) end |
#to_s ⇒ String
26 27 28 |
# File 'lib/matchi/be.rb', line 26 def to_s "be #{@expected.inspect}" end |