Skip to content

Instantly share code, notes, and snippets.

@kieraneglin
Last active December 18, 2017 16:55
Show Gist options
  • Save kieraneglin/90c6e559eb4fe21cdb5529aa730fbcda to your computer and use it in GitHub Desktop.
Save kieraneglin/90c6e559eb4fe21cdb5529aa730fbcda to your computer and use it in GitHub Desktop.
assert_differences new syntax example
assert_differences(['User.count', 'Post.count'], by: [-1, -5]) do
# Logic...
end
assert_differences('User.count', by: -1) do
# Logic... (although you should be using assert_difference in this case)
end
assert_differences(-> { User.count }, by: -1) do
# I can do lambdas too!
end
assert_differences('User.count', by: -5, message: 'No can do, kiddo') do
# Logic which shows your message on failure
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment