Understanding assert_difference in Ruby on Rails

Viewed 9667

Could anyone please explain what this test code does? :

assert_difference('Post.count') do
    post :create, :post => { :title => 'Hi', :body => 'This is my first post.'}
end

and:

assert_difference 'ActionMailer::Base.deliveries.size', +1 do
  post :invite_friend, :email => 'friend@example.com'
end

I can't understand it even though I read the documentation.

Thanks!

4 Answers
Related