Rspec email_spec issue

前端 未结 1 1935
栀梦
栀梦 2020-12-21 21:12

I am going through this User Authentication tutorial..

http://larsgebhardt.de/user-authentication-with-ruby-on-rails-rspec-and-capybara/

..which uses the gem

相关标签:
1条回答
  • 2020-12-21 22:00

    There are two problems to fix here.

    Firstly, there is the notice from the email_spec gem. To get rid of this, simply require action_mailer before email_spec in your rails_helper.rb:

    require "action_mailer"
    require "email_spec"
    

    Actually the email_spec gem will do this for you (hence the notice), but if you want to get rid of the pesky message, this is the solution.

    Secondly, there is the issue of config.include(UserHelper). This is actually unrelated to the first issue, and happens because the support/user_helper.rb file is not included when you try to reference the UserHelper module.

    The reason this happens is because the article you're following was written before RSpec 3, and thus before the Rails configurations moved to the rspec_helper.rb file. (More information on the upgrade here: https://www.relishapp.com/rspec/rspec-rails/docs/upgrade)

    To resolve the problem:

    1. Uncomment this line from rails_helper.rb:

      Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }

      This will load all your files from the spec/support directory tree.

    2. Move all your configurations from spec_helper.rb to rails_helper.rb.

    0 讨论(0)
提交回复
热议问题