我应该使用“rake spec"吗?或“rspec"(不能让“耙规范"工作)? [英] Should I use "rake spec" or "rspec" (can't get "rake spec" to work)?

查看:36
本文介绍了我应该使用“rake spec"吗?或“rspec"(不能让“耙规范"工作)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Rails 3.2 上使用 rspec (2.11.1).当我使用rake spec"运行我的测试套件时,我会失败.当我用rspec"运行它时,一切都过去了.我已经看到其他人提到过这个问题,但没有任何明确的解释可以解释正在发生的事情以及最佳做法是什么.

I am on Rails 3.2 and I am using rspec (2.11.1). When I run my test suite with "rake spec" I get failures. When I run it with "rspec" everything passes. I've seen other mentions of this problem but nothing definitive that explains what is going on and what best practices are.

如果我执行rake spec"或rake tmp:clear && rake spec",我的测试就会失败.

If I do "rake spec" or "rake tmp:clear && rake spec" my tests fail.

如果我执行rspec"或rspec spec"或rake db:test:prepare && rspec",我的测试就会通过.

If I do "rspec" or "rspec spec" or "rake db:test:prepare && rspec" my tests pass.

我认为唯一的区别是 rake 执行了db:test:prepare",但如果我在运行 rspec 之前手动执行此操作,我的测试就会通过,所以这不是全部.

I thought the only difference was that rake did "db:test:prepare" but if I do that manually before running rspec my tests pass so that can't be all of the story.

在阅读了一些资料后,我更改了我的 Gemfile.以前,我按照The RSpec Book"(p328)对其进行了设置,其中描述了将 rspec gem 放入group :development, :test"块中.阅读了其他一些 SO 帖子后,我删除了 ":development" 并做了一个包.现在rake spec"什么都不做.rspec"仍然像以前一样工作.

After doing a bit of reading I changed my Gemfile. Previously I had it set up as per "The RSpec Book" (p328) where it described putting the rspec gem inside a "group :development, :test" block. Having read some other SO posts I removed ":development" and did a bundle. Now "rake spec" does nothing. "rspec" still works as before.

很困惑...

推荐答案

尝试运行 RAILS_ENV=test rake spec

这篇关于我应该使用“rake spec"吗?或“rspec"(不能让“耙规范"工作)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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