Rspec email_spec问题 [英] Rspec email_spec issue

查看:217
本文介绍了Rspec email_spec问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在通过此用户身份验证教程。



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



..它使用gem'email_spec'。授予作者正在使用较早版本的rails和rspec,我有问题让gem正常工作。



添加..



spec_helper.rb

  RSpec.configure do | config | 
...
config.include(EmailSpec :: Helpers)
config.include(EmailSpec :: Matchers)
...
end

我收到此错误..

  Pony和ActionMailer都没有加载,所以email-spec需要ActionMailer。 
WARN:在Gem :: Specification.reset期间未解析的规格:
minitest(〜> 5.1)
rack-test(〜> 0.6.2)
WARN:清除未解决的规格。
如果这导致问题,请报告错误。

我仍然可以看到预期的测试失败,所以我继续,但是一旦我到达了它所在的部分让我向spec_helper添加 config.include(UserHelper),破解了宝石或测试套件。



这边的轨道和rspec是有点超过我的头。任何帮助,高度赞赏。



我目前正在运行Rails 4.1.6和Rspec 3.1.7。

解决方案



首先,从 email_spec gem发出通知。为了避免这种情况,只需在 rails_helper.rb 之前 action_mailer email_spec code $:
$ b $ pre $ requireaction_mailer
requireemail_spec

$ b

实际上, email_spec gem会为你做这件事(因此是通知),但第二,存在 config.include(UserHelper)的问题,如果你想摆脱讨厌的消息,这是解决方案。

。这实际上与第一个问题无关,并且是因为当您尝试引用 UserHelper 时不包含 support / user_helper.rb code> module。



发生这种情况的原因是因为您所遵循的文章是在RSpec 3之前编写的,因此在将Rails配置移动到 rspec_helper.rb 文件。 (有关升级的更多信息,请访问: https://www.relishapp.com/rspec / rspec-rails / docs / upgrade



解决问题:


  1. rails_helper.rb 取消注释:

    Dir [Rails.root.join(spec / support / ** / *。rb)]。each {| f |需要f}



    这会从 spec / support 目录加载所有文件将所有配置从 spec_helper.rb 移动到 rails_helper。

  2. rb



I am going through this User Authentication tutorial..

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

..which uses the gem 'email_spec'. Granted the author is using an earlier version of rails and rspec, I am having issues getting the gem to work properly.

When adding..

spec_helper.rb

RSpec.configure do |config|
...
config.include(EmailSpec::Helpers)
config.include(EmailSpec::Matchers)
...
end

I receive the error..

Neither Pony nor ActionMailer appear to be loaded so email-spec is requiring ActionMailer.
WARN: Unresolved specs during Gem::Specification.reset:
      minitest (~> 5.1)
      rack-test (~> 0.6.2)
WARN: Clearing out unresolved specs.
Please report a bug if this causes problems.

I can still see the expected test failures so I continued, but once I got to the part where it had me add config.include(UserHelper) to the spec_helper, the gem or test suite broke.

This side of rails and rspec is a little over my head. Any help is highly appreciated.

I am currently running Rails 4.1.6 and Rspec 3.1.7.

解决方案

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.

这篇关于Rspec email_spec问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆