I wrote an RSpec integration test. According to test.log, I see that he sent the email, but when I try to access the email using ActionMailer :: Base.deliveries, it always shows that it is empty.
I read other similar questions and tried everything. I'm at a dead end.
Here is the code using Capybara / RSpec:
it "should notify owner" do puts "Delivery method: #{ActionMailer::Base.delivery_method.inspect}" # This returns: ":test", which is correct # Get other guests to do the review @review = Review.last share_link = "http://#{@account.subdomain}.cozimo.local:#{Capybara.server_port}/review/#{@review.slug}" visit(share_link) fill_in "email", :with => @user1.email fill_in "password", :with => "foobar" click_button "Start Review" # Add a comment click_on "ice-global-note-button" find(:css, "#ice-global-note-panel > textarea.ui-corner-all").set "Foo" click_on "ice-global-note-submit-button" # Test is failing here. WTF? The array should not be empty ActionMailer::Base.deliveries.empty?.should be_false # Check that a notification email was sent to the owner open_email(@owner.email) current_email.should have_content "Hi #{@owner.first_name}" end
As you can see above, config.action_mailer.delivery_method =: test
In test.log, it shows that the email is indeed sent!
Sent mail to somebody1@example.com (62ms) Date: Tue, 29 Jan 2013 13:53:48 -0500 From: Review Studio < support@cozimo.com > To: somebody1@example.com Message-ID: < 51081abcd9fbf_5bd23fef87b264a08066@Leonards-MacBook-Pro.local.ma il> Subject: Notes added for Test Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Hi Bruce, Just letting you know that you have new notes added to the review: Project: Test Description: Test description URL: http://ballistiq.cozimo.local:3000/review/625682740 Thanks, Review Studio Completed 200 OK in 170ms (Views: 0.2ms | ActiveRecord: 4.3ms)
source share