Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

ActionMailer::Base incompatible with Rack::Test::Methods

#4557

I'm using Rack::Test::Methods to do request testing, and this appears to be incompatible with any ActionMailer use.
I understand that this may be the fault of Rack::Test::Methods as opposed to ActionMailer. If so, some tip on how to deal with it would be appreciated.

How to reproduce:

 1016  rails mail_break
 1017  cd mail_break/
 1018  mkdir app/views/moo
 1019  touch app/views/moo/cow.html.erb
 1020  rails console | tee log.txt
 1021  cat log
 1022  cat log.txt

Loading development environment (Rails 3.0.0.beta3)
no such file to load -- ap
ruby-1.9.1-p378 > class Moo < ActionMailer::Base
ruby-1.9.1-p378 ?>    def cow
ruby-1.9.1-p378 ?>        mail(:to => 'you@you.com', :from => 'me@me.com', :subject => 'breakage')
ruby-1.9.1-p378 ?>        end
ruby-1.9.1-p378 ?>    end
 => nil 
ruby-1.9.1-p378 > include Rack::Test::Methods
 => Object 
ruby-1.9.1-p378 > Moo.cow.deliver
ArgumentError: wrong number of arguments (0 for 1)
    from /Users/daniel/.rvm/gems/ruby-1.9.1-p378/gems/actionpack-3.0.0.beta3/lib/action_view/base.rb:211:in `initialize'
    from /Users/daniel/.rvm/gems/ruby-1.9.1-p378/gems/actionpack-3.0.0.beta3/lib/abstract_controller/rendering.rb:85:in `new'
    from /Users/daniel/.rvm/gems/ruby-1.9.1-p378/gems/actionpack-3.0.0.beta3/lib/abstract_controller/rendering.rb:85:in `view_context'
    from /Users/daniel/.rvm/gems/ruby-1.9.1-p378/gems/actionpack-3.0.0.beta3/lib/abstract_controller/rendering.rb:113:in `_render_template'
    from /Users/daniel/.rvm/gems/ruby-1.9.1-p378/gems/actionpack-3.0.0.beta3/lib/abstract_controller/rendering.rb:107:in `render_to_body'
    from /Users/daniel/.rvm/gems/ruby-1.9.1-p378/gems/actionpack-3.0.0.beta3/lib/abstract_controller/rendering.rb:100:in `render_to_string'
    from /Users/daniel/.rvm/gems/ruby-1.9.1-p378/gems/actionpack-3.0.0.beta3/lib/abstract_controller/rendering.rb:91:in `render'
    from /Users/daniel/.rvm/gems/ruby-1.9.1-p378/gems/actionmailer-3.0.0.beta3/lib/action_mailer/deprecated_api.rb:103:in `render'
    from /Users/daniel/.rvm/gems/ruby-1.9.1-p378/gems/actionmailer-3.0.0.beta3/lib/action_mailer/base.rb:606:in `block in collect_responses_and_parts_order'
    from /Users/daniel/.rvm/gems/ruby-1.9.1-p378/gems/actionmailer-3.0.0.beta3/lib/action_mailer/base.rb:621:in `each'
    from /Users/daniel/.rvm/gems/ruby-1.9.1-p378/gems/actionmailer-3.0.0.beta3/lib/action_mailer/base.rb:621:in `block in each_template'
    from /Users/daniel/.rvm/gems/ruby-1.9.1-p378/gems/actionmailer-3.0.0.beta3/lib/action_mailer/base.rb:616:in `each'
    from /Users/daniel/.rvm/gems/ruby-1.9.1-p378/gems/actionmailer-3.0.0.beta3/lib/action_mailer/base.rb:616:in `each_template'
    from /Users/daniel/.rvm/gems/ruby-1.9.1-p378/gems/actionmailer-3.0.0.beta3/lib/action_mailer/base.rb:602:in `collect_responses_and_parts_order'
    from /Users/daniel/.rvm/gems/ruby-1.9.1-p378/gems/actionmailer-3.0.0.beta3/lib/action_mailer/base.rb:548:in `mail'
    from (irb):3:in `cow'
    from /Users/daniel/.rvm/gems/ruby-1.9.1-p378/gems/actionpack-3.0.0.beta3/lib/abstract_controller/base.rb:153:in `send'
    from /Users/daniel/.rvm/gems/ruby-1.9.1-p378/gems/actionpack-3.0.0.beta3/lib/abstract_controller/base.rb:153:in `process_action'
    from /Users/daniel/.rvm/gems/ruby-1.9.1-p378/gems/actionpack-3.0.0.beta3/lib/abstract_controller/base.rb:123:in `process'
    from /Users/daniel/.rvm/gems/ruby-1.9.1-p378/gems/actionpack-3.0.0.beta3/lib/abstract_controller/rendering.rb:39:in `process'
    from /Users/daniel/.rvm/gems/ruby-1.9.1-p378/gems/actionmailer-3.0.0.beta3/lib/action_mailer/old_api.rb:74:in `process'
    from /Users/daniel/.rvm/gems/ruby-1.9.1-p378/gems/actionmailer-3.0.0.beta3/lib/action_mailer/base.rb:380:in `process'
    from /Users/daniel/.rvm/gems/ruby-1.9.1-p378/gems/actionmailer-3.0.0.beta3/lib/action_mailer/base.rb:375:in `initialize'
    from /Users/daniel/.rvm/gems/ruby-1.9.1-p378/gems/actionmailer-3.0.0.beta3/lib/action_mailer/base.rb:359:in `new'
    from /Users/daniel/.rvm/gems/ruby-1.9.1-p378/gems/actionmailer-3.0.0.beta3/lib/action_mailer/base.rb:359:in `method_missing'
    from (irb):7
    from /Users/daniel/.rvm/gems/ruby-1.9.1-p378/gems/railties-3.0.0.beta3/lib/rails/commands/console.rb:47:in `start'
    from /Users/daniel/.rvm/gems/ruby-1.9.1-p378/gems/railties-3.0.0.beta3/lib/rails/commands/console.rb:8:in `start'
    from /Users/daniel/.rvm/gems/ruby-1.9.1-p378/gems/railties-3.0.0.beta3/lib/rails/commands.rb:34:in `'
    from script/rails:9:in `require'
    from script/rails:9:in `'ruby-1.9.1-p378 > 
ruby-1.9.1-p378 >   exit

 1023  history

Reported by eydaimon · May 9th, 2010 @ 05:47 AM

State: invalid
Milestone: none
Assigned to: Ryan Bigg Ryan Bigg
Importance: none

Activity

  1. eydaimon
    eydaimon

    I solved my issue by putting Rack::Test::Methods only in the scope I needed it for. In my case since I use rspec:

    class Rspec::Core::ExampleGroup
    # this include really screws up ActionMailer so we put it only in the scope # where it's needed. include Rack::Test::Methods end

    May 9th, 2010 @ 08:55 AM

  2. eydaimon
    eydaimon

    better formatting here...

    class Rspec::Core::ExampleGroup
      # this include really screws up ActionMailer so we put it only in the scope
      # where it's needed.
      include Rack::Test::Methods
    end
    

    May 9th, 2010 @ 08:56 AM

  3. Dan Pickett
    Dan Pickett
    • Assigned user changed from Mikel Lindsaar to Ryan Bigg

    Ryan, I'm thinking this should be marked as invalid or wontfix.

    Thanks!

    May 9th, 2010 @ 06:37 PM

  4. Ryan Bigg
    Ryan Bigg
    • State changed from new to invalid

    May 9th, 2010 @ 10:18 PM