Could anyone please explain what this test code does? :
assert_difference(\'Post.count\') do
post :create, :post => { :title => \'Hi\', :body => \'T
assert_difference verifies that the result of evaluating its first argument (a String which can be passed to eval
) changes by a certain amount after calling the block it was passed. The first example above could be "unrolled" to:
before = Post.count # technically, eval("Post.count")
post :create, :post => { :title => 'Hi', :body => 'This is my first post.'}
after = Post.count
assert_equal after, before + 1