Class: Matchi::Satisfy
- Inherits:
-
Object
- Object
- Matchi::Satisfy
- Defined in:
- lib/matchi/satisfy.rb
Overview
Satisfy matcher.
Instance Method Summary collapse
-
#initialize(&block) ⇒ Satisfy
constructor
Initialize the matcher with a block.
-
#match? ⇒ Boolean
Boolean comparison between the actual value and the expected value.
-
#to_s ⇒ String
Returns a string representing the matcher.
Constructor Details
#initialize(&block) ⇒ Satisfy
Initialize the matcher with a block.
14 15 16 17 18 |
# File 'lib/matchi/satisfy.rb', line 14 def initialize(&block) raise ::ArgumentError, "a block must be provided" unless block_given? @expected = block end |
Instance Method Details
#match? ⇒ Boolean
Boolean comparison between the actual value and the expected value.
32 33 34 35 36 |
# File 'lib/matchi/satisfy.rb', line 32 def match? raise ::ArgumentError, "a block must be provided" unless block_given? @expected.call(yield) end |
#to_s ⇒ String
Returns a string representing the matcher.
41 42 43 |
# File 'lib/matchi/satisfy.rb', line 41 def to_s "satisfy &block" end |