运行我的控制器的rspec测试时出现Rspec错误

时间:2011-10-19 12:06:10

标签: ruby-on-rails ruby-on-rails-3 rspec ruby-on-rails-3.1 rspec2

我正在开发 Rails v2.3 应用程序。

当我通过执行命令运行 rspec 测试时:

rspec spec/controllers/my_controller_spec.rb

我收到了错误消息,如下所示:

/.rvm/gems/ruby-1.8.7-p352@myapp/gems/rspec-core-2.6.4/lib/rspec/core/configuration.rb:427:in `raise_if_rspec_1_is_loaded':  (RuntimeError)
********************************************************************************
  You are running rspec-2, but it seems as though rspec-1 has been loaded as
  well.  This is likely due to a statement like this somewhere in the specs:

      require 'spec'

  Please locate that statement, remove it, and try again.
********************************************************************************
/.rvm/gems/ruby-1.8.7-p352@myapp/gems/rspec-core-2.6.4/lib/rspec/core/configuration.rb:420:in `load_spec_files'

---- ---更新

由于它抱怨某个包含代码require 'spec'的文件,所以我按照这个线索在 spec / spec_helper.rb 中找到“require 'spec'”,但是,在我删除之后,相同的错误仍然会升高,我现在没有任何其他文件包含该代码。

为什么错误仍然存​​在,那么真正的原因是什么?

1 个答案:

答案 0 :(得分:5)

rspecrspec-2的可执行文件。 specrspec-1的可执行文件。 rspec-2rails 2.3不兼容。你的命令应该是:

spec spec/controllers/my_controller_spec.rb