Rspec error when I run my rspec test of my controller

独自空忆成欢 提交于 2020-01-06 14:10:57

问题


I am developing a Rails v2.3 application.

When I run the rspec test by execute command:

rspec spec/controllers/my_controller_spec.rb

I got the error message which is showing below:

/.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'

----update---

Since it complains about some file which contain the code require 'spec', so I follow this clue and I found "require 'spec'" in spec/spec_helper.rb , However, after I removed it , the same error still raise up, and I don't have any other file contain the code now.

Why the error still coming, what is the real cause then?


回答1:


rspec is the executable for rspec-2. spec is the executable for rspec-1. rspec-2 is not compatible with rails 2.3. Your command should be:

spec spec/controllers/my_controller_spec.rb


来源:https://stackoverflow.com/questions/7821020/rspec-error-when-i-run-my-rspec-test-of-my-controller

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!