Class: Matchi::Change
- Inherits:
-
Object
- Object
- Matchi::Change
- Defined in:
- lib/matchi/change.rb,
lib/matchi/change/by.rb,
lib/matchi/change/to.rb,
lib/matchi/change/from.rb,
lib/matchi/change/from/to.rb,
lib/matchi/change/by_at_most.rb,
lib/matchi/change/by_at_least.rb
Overview
Wraps the target of a change matcher.
Defined Under Namespace
Classes: By, ByAtLeast, ByAtMost, From, To
Instance Method Summary collapse
-
#by(delta) ⇒ #match?
Specifies the delta of the expected change.
-
#by_at_least(minimum_delta) ⇒ #match?
Specifies a minimum delta of the expected change.
-
#by_at_most(maximum_delta) ⇒ #match?
Specifies a maximum delta of the expected change.
-
#from(old_value) ⇒ #match?
Specifies the original value.
-
#initialize(object, method) ⇒ Change
constructor
Initialize a wrapper of the change matcher with an object and the name of one of its methods.
-
#to(new_value) ⇒ #match?
Specifies the new value to expect.
Constructor Details
#initialize(object, method) ⇒ Change
Initialize a wrapper of the change matcher with an object and the name of one of its methods.
22 23 24 25 26 27 |
# File 'lib/matchi/change.rb', line 22 def initialize(object, method, ...) raise ::ArgumentError, "method must be a Symbol" unless method.is_a?(::Symbol) raise ::ArgumentError, "object must respond to method" unless object.respond_to?(method) @state = -> { object.send(method, ...) } end |
Instance Method Details
#by(delta) ⇒ #match?
Specifies the delta of the expected change.
76 77 78 |
# File 'lib/matchi/change.rb', line 76 def by(delta) By.new(delta, &@state) end |
#by_at_least(minimum_delta) ⇒ #match?
Specifies a minimum delta of the expected change.
42 43 44 |
# File 'lib/matchi/change.rb', line 42 def by_at_least(minimum_delta) ByAtLeast.new(minimum_delta, &@state) end |
#by_at_most(maximum_delta) ⇒ #match?
Specifies a maximum delta of the expected change.
59 60 61 |
# File 'lib/matchi/change.rb', line 59 def by_at_most(maximum_delta) ByAtMost.new(maximum_delta, &@state) end |