简体   繁体   English

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

[英]Rspec error when I run my rspec test of my controller

I am developing a Rails v2.3 application. 我正在开发Rails v2.3应用程序。

When I run the rspec test by execute command: 当我通过execute命令运行rspec测试时:

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. 由于它抱怨某些包含代码require 'spec' ,因此我遵循了这一提示,并且在spec / spec_helper.rb中发现了“ require'spec require 'spec' ”, 但是 ,在删除它之后, 仍然出现相同的错误 ,而且我现在没有任何其他文件包含代码。

Why the error still coming, what is the real cause then? 为什么错误仍然存​​在,真正的原因是什么?

rspec is the executable for rspec-2 . rspecrspec-2的可执行文件。 spec is the executable for rspec-1 . specrspec-1的可执行文件。 rspec-2 is not compatible with rails 2.3 . rspec-2rails 2.3不兼容。 Your command should be: 您的命令应为:

spec spec/controllers/my_controller_spec.rb

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM