lib/bacon-expect/matchers/change.rb in bacon-expect-1.0.2 vs lib/bacon-expect/matchers/change.rb in bacon-expect-1.0.3
- old
+ new
@@ -12,18 +12,17 @@
def matches?(subject, &expectation_block)
old_value = @change_block.call
expectation_block.call
new_value = @change_block.call
if @change_amount
- new_value - @change_amount == old_value
+ @value_diff = new_value - old_value
+ @value_diff == @change_amount
else
new_value != old_value
end
end
- def fail!(subject)
- message = "Block expected to change value"
- message += " by #{@change_amount}" if @change_amount
- raise FailedExpectation.new(message)
+ def fail!(subject, negated)
+ raise FailedExpectation.new(FailMessageRenderer.message_for_change(negated, @change_amount, @value_diff))
end
end
end; end
\ No newline at end of file