assert_difference has morphed
May 27th, 2007
This is just a little note that assert_difference, the ultimate test helper, has been merged into core. The only issue is that it has changed a bit from the version that I have used. I always used something along the lines of:
assert_difference Post, :count do
Post.create_valid
end
The version that got merged into core instead accepts a string like so:
assert_difference 'Post.count' do
Post.create_valid
end
Not sure why the syntax is different but that is neither here nor there for me. The only down side is I had to go through all my tests and fix the incorrect arguments. Just thought I would say something here so others know what is going wrong when all their tests fail after upgrading to edge.

May 28th, 2007 at 10:40 AM
Try asserting the difference on post.comments.size with the old syntax and you’ll see why it changed ;)
May 28th, 2007 at 09:51 PM
Well, I trusted that it was for the best. :) Thanks for the example.
December 19th, 2007 at 05:29 PM
I’m using Rails 2.0.1 and the ‘Post.count’ syntax doesn’t seem to be working. I get TypeError: nil is not a symbol. The old syntax works though :-)