Class: Matchi::Change::To
- Inherits:
-
Object
- Object
- Matchi::Change::To
- Defined in:
- lib/matchi/change/to.rb
Overview
*Change to* matcher.
Instance Attribute Summary collapse
-
#expected ⇒ #object_id
readonly
An expected new value.
Instance Method Summary collapse
-
#initialize(expected, &state) ⇒ To
constructor
Initialize the matcher with an object and a block.
-
#inspect ⇒ Object
A string containing a human-readable representation of the matcher.
-
#matches? ⇒ Boolean
Boolean comparison on the expected change by comparing the value before and after the code execution.
-
#to_s ⇒ Object
Returns a string representing the matcher.
Constructor Details
#initialize(expected, &state) ⇒ To
Initialize the matcher with an object and a block.
22 23 24 25 |
# File 'lib/matchi/change/to.rb', line 22 def initialize(expected, &state) @expected = expected @state = state end |
Instance Attribute Details
#expected ⇒ #object_id (readonly)
Returns An expected new value.
8 9 10 |
# File 'lib/matchi/change/to.rb', line 8 def expected @expected end |
Instance Method Details
#inspect ⇒ Object
A string containing a human-readable representation of the matcher.
52 53 54 |
# File 'lib/matchi/change/to.rb', line 52 def inspect "#{self.class}(#{expected.inspect})" end |
#matches? ⇒ Boolean
Boolean comparison on the expected change by comparing the value before and after the code execution.
44 45 46 47 48 49 |
# File 'lib/matchi/change/to.rb', line 44 def matches? yield value_after = @state.call expected == value_after end |
#to_s ⇒ Object
Returns a string representing the matcher.
57 58 59 |
# File 'lib/matchi/change/to.rb', line 57 def to_s "change to #{expected.inspect}" end |