0

我正在開發一個Rails v2.3應用程序。Rspec錯誤,當我運行我的控制器的rspec測試

當運行RSpec的測試通過執行命令:

rspec spec/controllers/my_controller_spec.rb

我得到的錯誤消息這將在下面示出:

/.rvm/gems/[email protected]/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/[email protected]/gems/rspec-core-2.6.4/lib/rspec/core/configuration.rb:420:in `load_spec_files' 

----更新---

由於它抱怨它包含的代碼require 'spec'一些文件,所以我遵循這個線索,我在規格/ spec_helper.rb然而發現「require 'spec'」,我刪除它之後,同樣的錯誤仍然提高up,而我現在沒有任何其他文件包含代碼。

爲什麼錯誤還在後面,那麼究竟是什麼原因呢?

+0

config/test.rb和spec_helper文件是怎麼查找的? –

+0

@Alok,我在confi/test.rb中發現了「require'spec'」,在我刪除它之後,同樣的錯誤仍然出現,並且我沒有任何其他文件包含代碼 –

回答

5

rspecrspec-2的可執行文件。 specrspec-1的可執行文件。 rspec-2rails 2.3不兼容。你的命令應該是:

spec spec/controllers/my_controller_spec.rb