Return to Snippet

Revision: 2237
at January 21, 2007 16:47 by vanne


Initial Code
def assert_difference(object, method, difference=1)
  initial_value = object.send(method)
  yield
  assert_equal initial_value + difference, object.send(method)
end

Initial URL
http://weblog.jamisbuck.org/2007/1/19/blocks-rock

Initial Description
A custom assertion that will allow you to pass a block to find the difference between two values.

Initial Title
assert_difference

Initial Tags
ruby

Initial Language
Ruby