Posted By

vanne on 01/21/07


Tagged

ruby


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

webstic


assert_difference


 / Published in: Ruby
 

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

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

  1. def assert_difference(object, method, difference=1)
  2. initial_value = object.send(method)
  3. yield
  4. assert_equal initial_value + difference, object.send(method)
  5. end

Report this snippet  

You need to login to post a comment.