Created
November 11, 2010 13:07
-
-
Save moiristo/672465 to your computer and use it in GitHub Desktop.
Test helper method to perform multiple assert_difference calls easily.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Example | |
assert_differences 'Initiative.count' => 1, 'Role.count' => -1, 'Phase.count' => 0 do | |
@initiative.to_template! | |
end | |
def assert_differences(collection = {}, &block) | |
yield and return if collection.empty? | |
collection.shift.tap do |diff| | |
assert_differences(collection){ assert_difference(diff.first, diff.last, &block) } | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment