Class: Matchi::Satisfy
- Inherits:
-
Object
- Object
- Matchi::Satisfy
- Defined in:
- lib/matchi/satisfy.rb
Overview
Satisfy matcher.
Instance Attribute Summary collapse
-
#expected ⇒ Proc
readonly
A block of code.
Instance Method Summary collapse
-
#initialize(&block) ⇒ Satisfy
constructor
Initialize the matcher with a block.
-
#inspect ⇒ Object
A string containing a human-readable representation of the matcher.
-
#matches? ⇒ Boolean
Boolean comparison between the actual value and the expected value.
-
#to_s ⇒ Object
Returns a string representing the matcher.
Constructor Details
#initialize(&block) ⇒ Satisfy
Initialize the matcher with a block.
17 18 19 |
# File 'lib/matchi/satisfy.rb', line 17 def initialize(&block) @expected = block end |
Instance Attribute Details
#expected ⇒ Proc (readonly)
Returns A block of code.
7 8 9 |
# File 'lib/matchi/satisfy.rb', line 7 def expected @expected end |
Instance Method Details
#inspect ⇒ Object
A string containing a human-readable representation of the matcher.
40 41 42 |
# File 'lib/matchi/satisfy.rb', line 40 def inspect "#{self.class}(&block)" end |
#matches? ⇒ Boolean
Boolean comparison between the actual value and the expected value.
35 36 37 |
# File 'lib/matchi/satisfy.rb', line 35 def matches? expected.call(yield) end |
#to_s ⇒ Object
Returns a string representing the matcher.
45 46 47 |
# File 'lib/matchi/satisfy.rb', line 45 def to_s "satisfy &block" end |