RSpec已被弃用

6

我正在进行几项测试,每次运行时都会收到以下警告:

DEPRECATION WARNING: you are using a deprecated constant that will
be removed from a future version of RSpec.

C:/Sites/injixo/spec/views/me_home_spec.rb:1in 'require'

*Rspec is deprecated
*Rspec is the new top-level module in RSpec-2

我已经安装了最新版本2.6.1的RSpec,所以我不确定为什么会出现这个警告。有人能解释一下这个问题以及如何去除它吗?

谢谢 JP

2个回答

16

问题很可能在spec/spec_helper.rb中,这个文件可能被你的测试用例所引用。顶层模块现在称为RSpec,而不是小写的s。关于你的问题,你必须手动输入了一些错误信息,而不是复制粘贴。你的spec_helper应该长这样:

# spec/spec_helper.rb
RSpec.configure do |config|
    ...
end

如果警告能说明一下就好了! - Ian Vaughan

4
我使用 guard 时遇到了这个错误。我只需要更改:
guard 'rspec', :version => 2 do

为了

guard 'rspec' do

Guardfile中。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接