Today I Learned

A Hashrocket project

🧮 assert_difference with negative values

ActiveSupport::Testing::Assertions can check that a value was reduced because of a block:

test 'should destroy' do
  assert_difference('User.count', -1) do
    delete :destroy, id:

#assert_difference has a default value of 1 so negative numbers must be explicit.


Looking for help? Each developer at Hashrocket has years of experience working with Ruby applications of all types and sizes. Contact us and find out how we can help you.