class MotionSpec::Matcher::Change
Public Class Methods
new(change_block)
click to toggle source
# File lib/motion-spec/matcher/change.rb, line 4 def initialize(change_block) @change_block = change_block end
Public Instance Methods
by(amount)
click to toggle source
# File lib/motion-spec/matcher/change.rb, line 8 def by(amount) @change_amount = amount self end
fail!(_subject, negated)
click to toggle source
# File lib/motion-spec/matcher/change.rb, line 25 def fail!(_subject, negated) fail FailedExpectation.new( FailMessageRenderer.message_for_change( negated, @change_amount, @value_diff ) ) end
matches?(_subject, &expectation_block)
click to toggle source
# File lib/motion-spec/matcher/change.rb, line 13 def matches?(_subject, &expectation_block) old_value = @change_block.call expectation_block.call new_value = @change_block.call if @change_amount @value_diff = new_value - old_value @value_diff == @change_amount else new_value != old_value end end