Skip to content
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

Email_spec causes rspec to fail (though not under Spring) #187

Open
davidham opened this issue Oct 26, 2016 · 5 comments
Open

Email_spec causes rspec to fail (though not under Spring) #187

davidham opened this issue Oct 26, 2016 · 5 comments

Comments

@davidham
Copy link

I installed email_spec per the instructions, but when I run rspec it fails with the following message:

/usr/local/bundle/gems/actionmailer-5.0.0.1/lib/action_mailer/rescuable.rb:6:in `<module:Rescuable>': uninitialized constant ActiveSupport::Rescuable (NameError)
    from /usr/local/bundle/gems/actionmailer-5.0.0.1/lib/action_mailer/rescuable.rb:4:in `<module:ActionMailer>'
    from /usr/local/bundle/gems/actionmailer-5.0.0.1/lib/action_mailer/rescuable.rb:1:in `<top (required)>'
    from /usr/local/bundle/gems/actionmailer-5.0.0.1/lib/action_mailer/base.rb:8:in `require'
    from /usr/local/bundle/gems/actionmailer-5.0.0.1/lib/action_mailer/base.rb:8:in `<top (required)>'
    from /usr/local/bundle/gems/email_spec-2.1.0/lib/email_spec/deliveries.rb:76:in `require'
    from /usr/local/bundle/gems/email_spec-2.1.0/lib/email_spec/deliveries.rb:76:in `<module:Deliveries>'
    from /usr/local/bundle/gems/email_spec-2.1.0/lib/email_spec/deliveries.rb:72:in `<module:EmailSpec>'
    from /usr/local/bundle/gems/email_spec-2.1.0/lib/email_spec/deliveries.rb:1:in `<top (required)>'
    from /usr/local/bundle/gems/email_spec-2.1.0/lib/email_spec.rb:10:in `require'
    from /usr/local/bundle/gems/email_spec-2.1.0/lib/email_spec.rb:10:in `<top (required)>'
    from /app/spec/spec_helper.rb:4:in `require'
    from /app/spec/spec_helper.rb:4:in `<top (required)>'
    from /usr/local/bundle/gems/rspec-core-3.5.2/lib/rspec/core/configuration.rb:1394:in `require'
    from /usr/local/bundle/gems/rspec-core-3.5.2/lib/rspec/core/configuration.rb:1394:in `block in requires='
    from /usr/local/bundle/gems/rspec-core-3.5.2/lib/rspec/core/configuration.rb:1394:in `each'
    from /usr/local/bundle/gems/rspec-core-3.5.2/lib/rspec/core/configuration.rb:1394:in `requires='
    from /usr/local/bundle/gems/rspec-core-3.5.2/lib/rspec/core/configuration_options.rb:112:in `block in process_options_into'
    from /usr/local/bundle/gems/rspec-core-3.5.2/lib/rspec/core/configuration_options.rb:111:in `each'
    from /usr/local/bundle/gems/rspec-core-3.5.2/lib/rspec/core/configuration_options.rb:111:in `process_options_into'
    from /usr/local/bundle/gems/rspec-core-3.5.2/lib/rspec/core/configuration_options.rb:21:in `configure'
    from /usr/local/bundle/gems/rspec-core-3.5.2/lib/rspec/core/runner.rb:99:in `setup'
    from /usr/local/bundle/gems/rspec-core-3.5.2/lib/rspec/core/runner.rb:86:in `run'
    from /usr/local/bundle/gems/rspec-core-3.5.2/lib/rspec/core/runner.rb:71:in `run'
    from /usr/local/bundle/gems/rspec-core-3.5.2/lib/rspec/core/runner.rb:45:in `invoke'
    from /usr/local/bundle/gems/rspec-core-3.5.2/exe/rspec:4:in `<top (required)>'
    from /usr/local/bundle/bin/rspec:17:in `load'
    from /usr/local/bundle/bin/rspec:17:in `<main>'

This is from my spec_helper.rb:

require 'action_mailer'
require 'email_spec'
require 'email_spec/rspec'

When I comment out the email_spec lines, Rspec runs again.

Strange thing though: when I run Rspec under Spring with bin/rspec, I don't see this issue. Any ideas why?

@davidham davidham changed the title Email_spec causes rspec to fail Email_spec causes rspec to fail (though not under Spring) Oct 26, 2016
@michaelrshannon
Copy link

@davidham I'm also seeing this under Rails 5 - did you have any luck solving this?

@davidham
Copy link
Author

davidham commented Nov 3, 2016

@michaelrshannon I'm afraid not, after trying many different things I had to uninstall it. I'm having a hard time with my email-related integration tests generally. I have a feature spec that is supposed to verify (among other things) that an email was sent, but the spec fails intermittently.

@sergiopantoja
Copy link
Contributor

@davidham @michaelrshannon Here's the fix. I was running into the same problem and finally traced it down.

In your rails_helper.rb, you need to require spec_helper after loading the environment. So change this:

require 'spec_helper'
require File.expand_path('../../config/environment', __FILE__)

to this:

require File.expand_path('../../config/environment', __FILE__)
require 'spec_helper'

It's safe to do this, and in fact this is how RSpec generates the rails_helper.rb file by default now anyways (see rspec/rspec-rails@b913f6a for reference).

@davidham
Copy link
Author

@sergiopantoja This is awesome, thanks for posting this! I wanted to use email-spec and I still have it commented out in my Gemfile, but I'll definitely give this a try.

@caseyprovost
Copy link

caseyprovost commented Jun 19, 2017

👍 I am still getting this error with the proposed fix above in Rails 5.0.0

jeremyyap added a commit to coursemology-collab/coursemology2 that referenced this issue Nov 28, 2017
Loading email-spec before config/environment was causing rspec to fail
email-spec/email-spec#187
etagwerker pushed a commit that referenced this issue Apr 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants