[rspec-users] Need Help with Specs failing when using ActionMailer

David Chelimsky dchelimsky at gmail.com
Thu Dec 10 04:55:46 EST 2009


On Wed, Dec 9, 2009 at 7:48 PM, Brad <brad.forsyth at inspire2go.com> wrote:
> No one was able to help me with the last post so I thought I would try
> again with more details.  I am having problems with specs that invoke
> the mailer.  My User model has a method that invokes a mailer as part
> of the create_from_signup method.
>
> First an example of the test that passes in my spec/models/user_spec
> when run in isolation (i.e. spec spec/models/user_spec.rb).
>
>    before do
>      UserNotifier.deliveries = []
>    end
>
>    it "should signup a valid user and send an activation e-mail" do
>      u = User.create_from_signup(params)
>      u.state.should == 'pending'
>      UserNotifier.should have(1).deliveries
>      mail = UserNotifier.deliveries.first
>      mail.to.should eql( [u.email] )
>      mail.subject.should eql( "#{u.login}, Please activate your new
> account" )
>    end
>
> The spec passes with no problems [ all green :) ]
>
> When I run this same spec within my entire suite (spec spec), it fails
> with the following backtrace
>
> ArgumentError in 'User Signup - should signup a valid user and send an
> activation e-mail"
> wrong number of arguments (0 for 1)
> ruby/lib/ruby/gems/1.8/gems/actionmailer-2.3.5/lib/action_mailer/
> base.rb:551:in 'content_type'
> ruby/lib/ruby/gems/1.8/gems/actionmailer-2.3.5/lib/action_mailer/
> base.rb:551:in 'render_message'
> ruby/lib/ruby/gems/1.8/gems/actionmailer-2.3.5/lib/action_mailer/
> base.rb:493:in 'create!'
> ruby/lib/ruby/gems/1.8/gems/actionmailer-2.3.5/lib/action_mailer/
> base.rb:452:in 'initialize'
> ruby/lib/ruby/gems/1.8/gems/actionmailer-2.3.5/lib/action_mailer/
> base.rb:395:in 'new'
> ruby/lib/ruby/gems/1.8/gems/actionmailer-2.3.5/lib/action_mailer/
> base.rb:395:in 'method_missing'
> rails/app/models/user.rb:150:in 'create_from_signup'

What's on line 150 in user.rb? Please post the entire method
surrounding that line.

> I get this same error in my user controller tests, whether I run it
> standalone or within the suite.
>
> Does anyone have any idea what could be causing this?
>
> Thanks in advance
>
> Brad


More information about the rspec-users mailing list