diff --git a/src/spectator/matchers/change_from_matcher.cr b/src/spectator/matchers/change_from_matcher.cr index 75e81db..82a9267 100644 --- a/src/spectator/matchers/change_from_matcher.cr +++ b/src/spectator/matchers/change_from_matcher.cr @@ -67,6 +67,11 @@ module Spectator::Matchers ChangeExactMatcher.new(@expression, @expected, value) end + # Specifies what the resulting value of the expression should change by. + def by(amount : T) forall T + ChangeExactMatcher.new(@expression, @expected, @expected + value) + end + # Performs the change and reports the before and after values. private def change(actual) before = expression.value # Retrieve the expression's initial value. diff --git a/src/spectator/matchers/change_to_matcher.cr b/src/spectator/matchers/change_to_matcher.cr index e95c1d9..65f1ce5 100644 --- a/src/spectator/matchers/change_to_matcher.cr +++ b/src/spectator/matchers/change_to_matcher.cr @@ -61,6 +61,11 @@ module Spectator::Matchers ChangeExactMatcher.new(@expression, value, @expected) end + # Specifies how much the initial value should change by. + def by(amount : T) forall T + ChangeExactMatcher.new(@expression, @expected - amount, @expected) + end + # Performs the change and reports the before and after values. private def change(actual) before = expression.value # Retrieve the expression's initial value.