This project is archived and is in readonly mode.

#4557 ✓invalid
eydaimon

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

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

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

Comments and changes to this ticket

  • eydaimon

    eydaimon May 9th, 2010 @ 08:55 AM

    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

  • eydaimon

    eydaimon May 9th, 2010 @ 08:56 AM

    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
    
  • Dan Pickett

    Dan Pickett May 9th, 2010 @ 06:37 PM

    • Assigned user changed from “Mikel Lindsaar” to “Ryan Bigg”

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

    Thanks!

  • Ryan Bigg

    Ryan Bigg May 9th, 2010 @ 10:18 PM

    • State changed from “new” to “invalid”

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Pages