Rspec找不到测试用例。

5

我有一个几乎全新的 Rails 3.1.0 应用程序,但 rspec 找不到我的示例。

duncan@duncan-notebook:~/myapp$ bundle exec rspec
No examples found.

Finished in 0.00004 seconds
0 examples, 0 failures

我的规格目录看起来像这样:

spec/
|-- controllers
|   `-- welcome_controller_spec.rb
|-- factories
|   `-- users.rb
|-- helpers
|   `-- welcome_helper_spec.rb
|-- models
|   `-- user_spec.rb
|-- spec_helper.rb
`-- views
    `-- welcome
        `-- index.html.haml_spec.rb

这里有一些例子,比如welcome_controller_spec.rb包含以下内容:

require 'spec_helper'    
describe WelcomeController do    
  describe "GET 'index'" do
    it "should be successful" do
      get 'index'
      response.should be_success
    end
  end
end

我正在使用以下版本的rspec及相关Gems:
  • rspec (2.6.0)
  • rspec-core (2.6.4)
  • rspec-expectations (2.6.0)
  • rspec-mocks (2.6.0)
  • rspec-rails (2.6.1)
  • rubyzip (0.9.4)
请问有人能告诉我如何让rspec找到我的示例?我怀疑这里缺少了一些非常简单的东西。
2个回答

6
我使用bundle exec rspec得到的结果也一样,可能这个命令已经被弃用了。尝试使用以下命令:
 rspec spec

rspec specbundle exec rspec spec 都可以很好地工作。谢谢 :-) - Duncan Bayne

3

@calebB在版本号小于等于2.6的时候是正确的,但是在2.7版本中,你不需要再加入该目录(它会默认为spec)。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接