On Dec 1, 3:14 pm, Zhi-Qiang Lei <[email protected]> wrote:
> http://stackoverflow.com/questions/8339957/actionmailer-test-failed-b...
>
> The ActionMailer in my Rails 3.1 project has an odd behavior, the 
> ActionMailer::Base.deliveries is empty in test while I can actually receive 
> the email by running the code in rails console. Anybody can points out what 
> wrong it is?
>
> # spec/mailers/user_mailer_spec.rb
> require "spec_helper"
>
> describe UserMailer do
>   describe ".reminding_email" do
>     subject { UserMailer.reminding_email(user).deliver }
>     let(:user) { create :confirmed_user_with_mass_tasks }
>     it "should be delivered" do
>       ActionMailer::Base.deliveries.should_not be_empty
>     end

IIRC subject is evaluated lazily, so in this example
UserMailer.reminding_email(user).deliver wouldn't be called at all

Fred

>     its(:to) { should == [user.email] }
>     its(:subject) { should == "Task Reminding" }
>   end
> end

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to