Skip to content

Rails 3.2.1 does not start with rspec-rails 3.2.2 #1386

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
tagliala opened this issue Jun 3, 2015 · 14 comments · Fixed by #1388
Closed

Rails 3.2.1 does not start with rspec-rails 3.2.2 #1386

tagliala opened this issue Jun 3, 2015 · 14 comments · Fixed by #1388

Comments

@tagliala
Copy link

tagliala commented Jun 3, 2015

It should be a consequence of #1327, as per #1327 (comment)

$ rails c
~/.rvm/gems/ruby-2.1.5/gems/actionmailer-3.2.21/lib/action_mailer/base.rb:438:in `method_missing': undefined method `preview_path=' for ActionMailer::Base:Class (NoMethodError)
@cupakromer
Copy link
Member

I'm looking into this now.

@myronmarston
Copy link
Member

Thanks for hopping on it so quickly, @cupakromer. I'll hold off on the 3.3 release until this is done (I think everything else on our 3.3 list already got done).

We should probably backport the fix to 3.2.3 as well, and I'll be happy to release that, too.

@cupakromer
Copy link
Member

I think I see the issue but I've been unable to reproduce the error. I'll need to be able to reproduce before I can ensure I've fixed the issue.

@tagliala if you could please update this issue with the following I'd really appreciate it:

  • full stack trace
  • output of ruby -v
  • output of rails -v

@cupakromer
Copy link
Member

also, @olance if you could provide additional details I would appreciate it

@olance
Copy link

olance commented Jun 3, 2015

Sure! There you go:

~/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/actionmailer-3.2.21/lib/action_mailer/base.rb:438:in `method_missing': undefined method `preview_path=' for ActionMailer::Base:Class (NoMethodError)
     from ~/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/actionmailer-3.2.21/lib/action_mailer/railtie.rb:34:in `block (3 levels) in <class:Railtie>'
     from ~/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/actionmailer-3.2.21/lib/action_mailer/railtie.rb:34:in `each'
     from ~/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/actionmailer-3.2.21/lib/action_mailer/railtie.rb:34:in `block (2 levels) in <class:Railtie>'
     from ~/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/activesupport-3.2.21/lib/active_support/lazy_load_hooks.rb:36:in `instance_eval'
     from ~/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/activesupport-3.2.21/lib/active_support/lazy_load_hooks.rb:36:in `execute_hook'
     from ~/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/activesupport-3.2.21/lib/active_support/lazy_load_hooks.rb:43:in `block in run_load_hooks'
     from ~/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/activesupport-3.2.21/lib/active_support/lazy_load_hooks.rb:42:in `each'
     from ~/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/activesupport-3.2.21/lib/active_support/lazy_load_hooks.rb:42:in `run_load_hooks'
     from ~/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/actionmailer-3.2.21/lib/action_mailer/base.rb:746:in `<class:Base>'
     from ~/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/actionmailer-3.2.21/lib/action_mailer/base.rb:326:in `<module:ActionMailer>'
     from ~/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/actionmailer-3.2.21/lib/action_mailer/base.rb:11:in `<top (required)>'
     from ~/dev/bmb_front/config/initializers/email.rb:2:in `<top (required)>'
     from ~/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/activesupport-3.2.21/lib/active_support/dependencies.rb:245:in `load'
     from ~/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/activesupport-3.2.21/lib/active_support/dependencies.rb:245:in `block in load'
     from ~/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/activesupport-3.2.21/lib/active_support/dependencies.rb:236:in `load_dependency'
     from ~/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/activesupport-3.2.21/lib/active_support/dependencies.rb:245:in `load'
     from ~/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/railties-3.2.21/lib/rails/engine.rb:593:in `block (2 levels) in <class:Engine>'
     from ~/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/railties-3.2.21/lib/rails/engine.rb:592:in `each'
     from ~/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/railties-3.2.21/lib/rails/engine.rb:592:in `block in <class:Engine>'
     from ~/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/railties-3.2.21/lib/rails/initializable.rb:30:in `instance_exec'
     from ~/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/railties-3.2.21/lib/rails/initializable.rb:30:in `run'
     from ~/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/railties-3.2.21/lib/rails/initializable.rb:55:in `block in run_initializers'
     from ~/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/railties-3.2.21/lib/rails/initializable.rb:54:in `each'
     from ~/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/railties-3.2.21/lib/rails/initializable.rb:54:in `run_initializers'
     from ~/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/railties-3.2.21/lib/rails/application.rb:136:in `initialize!'
     from ~/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/railties-3.2.21/lib/rails/railtie/configurable.rb:30:in `method_missing'
     from ~/dev/bmb_front/config/environment.rb:5:in `<top (required)>'
     from config.ru:4:in `require'
     from config.ru:4:in `block in <main>'
     from ~/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rack-1.4.5/lib/rack/builder.rb:51:in `instance_eval'
     from ~/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rack-1.4.5/lib/rack/builder.rb:51:in `initialize'
     from config.ru:1:in `new'
     from config.ru:1:in `<main>'
     from ~/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/unicorn-4.9.0/lib/unicorn.rb:48:in `eval'
     from ~/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/unicorn-4.9.0/lib/unicorn.rb:48:in `block in builder'
     from ~/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/unicorn-4.9.0/lib/unicorn/http_server.rb:768:in `call'
     from ~/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/unicorn-4.9.0/lib/unicorn/http_server.rb:768:in `build_app!'
     from ~/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/unicorn-4.9.0/lib/unicorn/http_server.rb:137:in `start'
     from ~/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/unicorn-4.9.0/bin/unicorn:126:in `<top (required)>'
     from ~/.rbenv/versions/2.1.2/bin/unicorn:23:in `load'
     from ~/.rbenv/versions/2.1.2/bin/unicorn:23:in `<main>'
$ bundle exec rails -v
Rails 3.2.21
$ bundle exec ruby -v 
ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-darwin14.0]

@olance
Copy link

olance commented Jun 3, 2015

From my debug session, I have found that around line 34 in ~/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/actionmailer-3.2.21/lib/action_mailer/railtie.rb, config.action_mailer already contained a value for :preview_path. It was set to a subdirectory of my project's specs dir.

I searched for preview_path in project's and my gems' directory and it was only found in rspec-rails.

@cupakromer
Copy link
Member

What's in ~/dev/bmb_front/config/initializers/email.rb? I see that is part of the trace. This does help shed a little more light on the order of operations.

@cupakromer
Copy link
Member

Ok, I've got it reproduced locally. The config is happy to take the option. The error only occurs once ActionMailer::Base is loaded. I'll start working on a fix with this assumption being what triggers your issue as well.

@tagliala
Copy link
Author

tagliala commented Jun 3, 2015

$ rails c
~/.rvm/gems/ruby-2.1.5/gems/actionmailer-3.2.21/lib/action_mailer/base.rb:438:in `method_missing': undefined method `preview_path=' for ActionMailer::Base:Class (NoMethodError)
    from ~/.rvm/gems/ruby-2.1.5/gems/actionmailer-3.2.21/lib/action_mailer/railtie.rb:34:in `block (3 levels) in <class:Railtie>'
    from ~/.rvm/gems/ruby-2.1.5/gems/actionmailer-3.2.21/lib/action_mailer/railtie.rb:34:in `each'
    from ~/.rvm/gems/ruby-2.1.5/gems/actionmailer-3.2.21/lib/action_mailer/railtie.rb:34:in `block (2 levels) in <class:Railtie>'
    from ~/.rvm/gems/ruby-2.1.5/gems/activesupport-3.2.21/lib/active_support/lazy_load_hooks.rb:36:in `instance_eval'
    from ~/.rvm/gems/ruby-2.1.5/gems/activesupport-3.2.21/lib/active_support/lazy_load_hooks.rb:36:in `execute_hook'
    from ~/.rvm/gems/ruby-2.1.5/gems/activesupport-3.2.21/lib/active_support/lazy_load_hooks.rb:26:in `block in on_load'
    from ~/.rvm/gems/ruby-2.1.5/gems/activesupport-3.2.21/lib/active_support/lazy_load_hooks.rb:25:in `each'
    from ~/.rvm/gems/ruby-2.1.5/gems/activesupport-3.2.21/lib/active_support/lazy_load_hooks.rb:25:in `on_load'
    from ~/.rvm/gems/ruby-2.1.5/gems/actionmailer-3.2.21/lib/action_mailer/railtie.rb:26:in `block in <class:Railtie>'
    from ~/.rvm/gems/ruby-2.1.5/gems/railties-3.2.21/lib/rails/initializable.rb:30:in `instance_exec'
    from ~/.rvm/gems/ruby-2.1.5/gems/railties-3.2.21/lib/rails/initializable.rb:30:in `run'
    from ~/.rvm/gems/ruby-2.1.5/gems/railties-3.2.21/lib/rails/initializable.rb:55:in `block in run_initializers'
    from ~/.rvm/gems/ruby-2.1.5/gems/railties-3.2.21/lib/rails/initializable.rb:54:in `each'
    from ~/.rvm/gems/ruby-2.1.5/gems/railties-3.2.21/lib/rails/initializable.rb:54:in `run_initializers'
    from ~/.rvm/gems/ruby-2.1.5/gems/railties-3.2.21/lib/rails/application.rb:136:in `initialize!'
    from ~/.rvm/gems/ruby-2.1.5/gems/railties-3.2.21/lib/rails/railtie/configurable.rb:30:in `method_missing'
    from ~/dev/project/config/environment.rb:5:in `<top (required)>'
    from ~/.rvm/gems/ruby-2.1.5/gems/activesupport-3.2.21/lib/active_support/dependencies.rb:251:in `require'
    from ~/.rvm/gems/ruby-2.1.5/gems/activesupport-3.2.21/lib/active_support/dependencies.rb:251:in `block in require'
    from ~/.rvm/gems/ruby-2.1.5/gems/activesupport-3.2.21/lib/active_support/dependencies.rb:236:in `load_dependency'
    from ~/.rvm/gems/ruby-2.1.5/gems/activesupport-3.2.21/lib/active_support/dependencies.rb:251:in `require'
    from ~/.rvm/gems/ruby-2.1.5/gems/railties-3.2.21/lib/rails/application.rb:103:in `require_environment!'
    from ~/.rvm/gems/ruby-2.1.5/gems/railties-3.2.21/lib/rails/commands.rb:40:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'
$ rails -v
Rails 3.2.21
$ ruby -v
ruby 2.1.5p273 (2014-11-13 revision 48405) [x86_64-darwin14.0]

/config/environment.rb

# Load the rails application
require File.expand_path('../application', __FILE__)

# Initialize the rails application
Project::Application.initialize!

/script/rails

#!/usr/bin/env ruby
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.

APP_PATH = File.expand_path('../../config/application',  __FILE__)
require File.expand_path('../../config/boot',  __FILE__)
require 'rails/commands'

@cupakromer
Copy link
Member

@tagliala @olance thank you both for reporting this 💙 I'm very sorry for causing this regression. I'll try to get the fix up by the end of the day.

@olance
Copy link

olance commented Jun 3, 2015

No worries! Thanks for fixing it so quickly!

cupakromer added a commit that referenced this issue Jun 3, 2015
This forces `ActionMailer::Base` to load, which then attempts to set the
configuration, exposing the regression issue in #1386.

Why the mailer generator and specs did not expose this problem is
currently a mystery. I will dig further.
@tagliala
Copy link
Author

tagliala commented Jun 3, 2015

@cupakromer thank you! no problem here 👍

cupakromer added a commit that referenced this issue Jun 4, 2015
This forces `ActionMailer::Base` to load, which then attempts to set the
configuration, exposing the regression issue in #1386.

Why the mailer generator and specs did not expose this problem is
currently a mystery. I will dig further.
cupakromer added a commit that referenced this issue Jun 4, 2015
This forces `ActionMailer::Base` to load, which then attempts to set the
configuration, exposing the regression issue in #1386.

Why the mailer generator and specs did not expose this problem is
currently a mystery. I will dig further.
cupakromer added a commit that referenced this issue Jun 4, 2015
This forces `ActionMailer::Base` to load, which then attempts to set the
configuration, exposing the regression issue in #1386.

Why the mailer generator and specs did not expose this problem is
currently a mystery. I will dig further.
cupakromer added a commit that referenced this issue Jun 4, 2015
This forces `ActionMailer::Base` to load, which then attempts to set the
configuration, exposing the regression issue in #1386.

Why the mailer generator and specs did not expose this problem is
currently a mystery. I will dig further.
cupakromer added a commit that referenced this issue Jun 4, 2015
This forces `ActionMailer::Base` to load, which then attempts to set the
configuration, exposing the regression issue in #1386.

Why the mailer generator and specs did not expose this problem is
currently a mystery. I will dig further.
cupakromer added a commit that referenced this issue Jun 4, 2015
This fixes the spec suite to expose issues with `ActionMailer` being
configured incorrectly when previews are not available.

This addresses several issues:

- The incorrect configuration options are only exposed once
  `ActionMailer::Base` is loaded; this forces the class to load in the
  mailer initializer and at the end of our script
- This adds specs specifically for the "development" environment which
  were missing before; it appeared that by not setting the environment
  it would default to "development" per the script, however, when the
  command shells out the `RAILS_ENV` is already set to "test" from rspec
  running.

  To be certain we cover the other possible edge cases we specifically
  add more tests for `ActionMailer` not being available, and for a
  custom configuration being set after `rspec-rails` is loaded.
- Despite us asking Rails to turn off eager loading in our custom
  script, several files were still getting eager loaded; this
  explicitly clears the eager load paths to stop this
- This fixes how the mailer script is shelled out in Ruby 1.8.7; now the
  environment variables are properly formatted and standard error is
  piped to standard out

Exposes the regression issue in #1386
cupakromer added a commit that referenced this issue Jun 5, 2015
This fixes the spec suite to expose issues with `ActionMailer` being
configured incorrectly when previews are not available.

This addresses several issues:

- The incorrect configuration options are only exposed once
  `ActionMailer::Base` is loaded; this forces the class to load in the
  mailer initializer and at the end of our script
- This adds specs specifically for the "development" environment which
  were missing before; it appeared that by not setting the environment
  it would default to "development" per the script, however, when the
  command shells out the `RAILS_ENV` is already set to "test" from rspec
  running.

  To be certain we cover the other possible edge cases we specifically
  add more tests for `ActionMailer` not being available, and for a
  custom configuration being set after `rspec-rails` is loaded.
- Despite us asking Rails to turn off eager loading in our custom
  script, several files were still getting eager loaded; this
  explicitly clears the eager load paths to stop this
- This fixes how the mailer script is shelled out in Ruby 1.8.7; now the
  environment variables are properly formatted and standard error is
  piped to standard out

Exposes the regression issue in #1386
@myronmarston
Copy link
Member

I just released 3.2.3 with @cupakromer's fix.

@tagliala
Copy link
Author

tagliala commented Jun 6, 2015

thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants