I like assert_difference, but I find the error messages slightly
unhelpful when I'm verifying more than one thing. Suppose something
should create both a new customer and a question, I could write
assert_difference 'Question.count' do
assert_difference 'Customer.count' do
...
end
end
Unlike a normal assertion the test line causing the failure will be a
few lines down the stack trace so it's not obvious to me with a quick
glance which of the assertions have failed (although this is fixable
by providing a custom failure message).
I'd rather write
assert_difference ['Question.count', 'Customer.count'] do
...
end
but if a failure occurs here then I genuinely don't know which
assertion has failed (unless I can remember that 'expected 4 got 3'
must be talking about the customer assertion because I remember the
number of records defined in the fixtures).
It seems to me that this could be made more helpful if the default
error message included the expression being evaluated eg something
along the lines of
Customer.count: expected 4, got 3
Thoughts?
Fred
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Core" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-core?hl=en
-~----------~----~----~----~------~----~------~--~---