Rails - How do you test ActionMailer sent a specific email in tests

Posted by adam on Stack Overflow See other posts from Stack Overflow or by adam
Published on 2010-01-14T10:30:27Z Indexed on 2010/05/12 3:34 UTC
Read the original article Hit count: 262

Currently in my tests I do something like this to test if an email is queued to be sent

    assert_difference('ActionMailer::Base.deliveries.size', 1) do       
        get :create_from_spreedly, {:user_id => @logged_in_user.id}
    end

but if i a controller action can send two different emails i.e. one to the user if sign up goes fine or a notification to admin if something went wrong - how can i test which one actually got sent. The code above would pass regardless.

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about actionmailer