问题
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