加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ruby-on-rails – Rails和RSpec:`rake spec`运行所有规格两次

发布时间:2020-12-17 03:31:58 所属栏目:百科 来源:网络整理
导读:我使用RSpec设置了一个新的Rails 4应用程序.但是当运行rake rspec时,所有示例都运行两次: rake spec[deprecated] I18n.enforce_available_locales will default to true in the future. If you really want to skip validation of your locale you can set
我使用RSpec设置了一个新的Rails 4应用程序.但是当运行rake rspec时,所有示例都运行两次:

rake spec
[deprecated] I18n.enforce_available_locales will default to true in the future. If you really want to skip validation of your locale you can set I18n.enforce_available_locales = false to avoid this message.
/Users/josh/.rvm/rubies/ruby-2.0.0-p353/bin/ruby -S rspec ./spec/controllers/dashboards_controller_spec.rb ./spec/models/member_spec.rb ./spec/requests/members_spec.rb ./spec/routing/members_routing_spec.rb
[deprecated] I18n.enforce_available_locales will default to true in the future. If you really want to skip validation of your locale you can set I18n.enforce_available_locales = false to avoid this message.
 11/11 |============================================ 100 ============================================>| Time: 00:00:00 

Finished in 0.21233 seconds
11 examples,0 failures

Randomized with seed 15954

/Users/josh/.rvm/rubies/ruby-2.0.0-p353/bin/ruby -S rspec ./spec/controllers/dashboards_controller_spec.rb ./spec/models/member_spec.rb ./spec/requests/members_spec.rb ./spec/routing/members_routing_spec.rb
[deprecated] I18n.enforce_available_locales will default to true in the future. If you really want to skip validation of your locale you can set I18n.enforce_available_locales = false to avoid this message.
 11/11 |============================================ 100 ============================================>| Time: 00:00:00 

Finished in 0.18831 seconds
11 examples,0 failures

Randomized with seed 24248

我已经找到了一些其他(旧的)问题,但无法为我找到解决方案.我该如何尝试调试?运行rspec就像一个魅力,但我很想知道这里有什么问题.

这是我的spec_helper.rb:
https://github.com/jmuheim/transition/blob/master/spec/spec_helper.rb

这是原始的Rails项目:
https://github.com/jmuheim/transition

更新

我发现规范rake任务似乎被定义了两次(注意/分隔每个任务的描述):

$rake -T | grep spec
...
rake spec                               # Run all specs in spec directory (excluding plugin specs) / Run RSpec code examples
...

其中一个是在spec目录中运行所有规范(不包括插件规范),一个是运行RSpec代码示例.

运行RSpec代码示例似乎来自rspec/core/rake_task.rb.运行spec目录中的所有规范(不包括插件规范)似乎来自rspec/rails/tasks/rspec.rake.

在我看来,只有其中一个应该存在?!

更新2

rspec-rails在测试和开发组中似乎都存在问题.我在这里添加了一个问题:https://github.com/rspec/rspec-rails/issues/904

解决方法

对我来说,这是由于我的.rspec文件中的重复条目.无法判断这是否是问题,因为.git文件位于.gitignore中,但基本上如果你这样做:

-- format progress
-- format documentation

在您的rspec文件中,您将看到两次测试输出.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读