未定义的方法“使用事务测试=';对于#<;RSpec::Core::配置:0x007fccf515e338>;(命名者)

未定义的方法“使用事务测试=';对于#<;RSpec::Core::配置:0x007fccf515e338>;(命名者),rspec,ruby-on-rails-5,Rspec,Ruby On Rails 5,我正在测试新的Rails版本5.0.0.alpha和RSpec3.1.7,但是我收到了错误: undefined method `use_transactional_tests=' for #<RSpec::Core::Configuration:0x007fccf515e338> (NoMethodError) 但我收到了这样的警告: DEPRECATION WARNING: use_transactional_fixtures= is deprecated and will b

我正在测试新的Rails版本
5.0.0.alpha
和RSpec
3.1.7
,但是我收到了错误:

undefined method `use_transactional_tests=' for #<RSpec::Core::Configuration:0x007fccf515e338> (NoMethodError)
但我收到了这样的警告:

DEPRECATION WARNING: use_transactional_fixtures= is deprecated and will be removed from Rails 5.0 (use use_transactional_tests= instead). (called from block in <module:FixtureSupport> at /Users/monteirobrena/.rvm/gems/ruby-2.2.2@global/gems/rspec-rails-3.1.0/lib/rspec/rails/fixture_support.rb:25)
现在我收到了这个错误:

/Users/monteirobrena/project/spec/rails_helper.rb:34:in `block in <top (required)>': undefined method `use_transactional_tests=' for #<RSpec::Core::Configuration:0x007fccf515e338> (NoMethodError)
from /Users/monteirobrena/.rvm/gems/ruby-2.2.2@global/gems/rspec-core-3.1.7/lib/rspec/core.rb:81:in `configure'
from /Users/monteirobrena/project/spec/rails_helper.rb:27:in `<top (required)>'
from /Users/monteirobrena/project/spec/controllers/messages_controller_spec.rb:1:in `require'
from /Users/monteirobrena/project/spec/controllers/messages_controller_spec.rb:1:in `<top (required)>'
from /Users/monteirobrena/.rvm/rubies/ruby-2.2.2/lib/ruby/gems/2.2.0/gems/rspec-core-3.1.7/lib/rspec/core/configuration.rb:1105:in `load'
from /Users/monteirobrena/.rvm/rubies/ruby-2.2.2/lib/ruby/gems/2.2.0/gems/rspec-core-3.1.7/lib/rspec/core/configuration.rb:1105:in `block in load_spec_files'
from /Users/monteirobrena/.rvm/rubies/ruby-2.2.2/lib/ruby/gems/2.2.0/gems/rspec-core-3.1.7/lib/rspec/core/configuration.rb:1105:in `each'
from /Users/monteirobrena/.rvm/rubies/ruby-2.2.2/lib/ruby/gems/2.2.0/gems/rspec-core-3.1.7/lib/rspec/core/configuration.rb:1105:in `load_spec_files'
from /Users/monteirobrena/.rvm/rubies/ruby-2.2.2/lib/ruby/gems/2.2.0/gems/rspec-core-3.1.7/lib/rspec/core/runner.rb:96:in `setup'
from /Users/monteirobrena/.rvm/rubies/ruby-2.2.2/lib/ruby/gems/2.2.0/gems/rspec-core-3.1.7/lib/rspec/core/runner.rb:84:in `run'
from /Users/monteirobrena/.rvm/rubies/ruby-2.2.2/lib/ruby/gems/2.2.0/gems/rspec-core-3.1.7/lib/rspec/core/runner.rb:69:in `run'
from /Users/monteirobrena/.rvm/rubies/ruby-2.2.2/lib/ruby/gems/2.2.0/gems/rspec-core-3.1.7/lib/rspec/core/runner.rb:37:in `invoke'
from /Users/monteirobrena/.rvm/gems/ruby-2.2.2@global/gems/rspec-core-3.1.7/exe/rspec:4:in `<top (required)>'
from /Users/monteirobrena/.rvm/rubies/ruby-2.2.2/bin/rspec:23:in `load'
from /Users/monteirobrena/.rvm/rubies/ruby-2.2.2/bin/rspec:23:in `<main>'
from /Users/monteirobrena/.rvm/gems/ruby-2.2.2@global/bin/ruby_executable_hooks:15:in `eval'
from /Users/monteirobrena/.rvm/gems/ruby-2.2.2@global/bin/ruby_executable_hooks:15:in `<main>'
/Users/monteirobrena/project/spec/rails\u helper.rb:34:in'block-in':未定义的方法'use\u transactional\u tests='for#(nomethoderor)
来自/Users/monteirobrena/.rvm/gems/ruby-2.2。2@global/gems/rspec-core-3.1.7/lib/rspec/core.rb:81:in'configure'
from/Users/monteirobrena/project/spec/rails\u helper.rb:27:in`'
from/Users/monteirobrena/project/spec/controllers/messages\u controller\u spec.rb:1:in'require'
from/Users/monteirobrena/project/spec/controllers/messages\u controller\u spec.rb:1:in`'
from/Users/monteirobrena/.rvm/rubies/ruby-2.2.2/lib/ruby/gems/2.2.0/gems/rspec-core-3.1.7/lib/rspec/core/configuration.rb:1105:in'load'
from/Users/monteirobrena/.rvm/rubies/ruby-2.2.2/lib/ruby/gems/2.2.0/gems/rspec-core-3.1.7/lib/rspec/core/configuration.rb:1105:“加载规范文件中的块”
from/Users/monteirobrena/.rvm/rubies/ruby-2.2.2/lib/ruby/gems/2.2.0/gems/rspec-core-3.1.7/lib/rspec/core/configuration.rb:1105:in'each'
from/Users/monteirobrena/.rvm/rubies/ruby-2.2.2/lib/ruby/gems/2.2.0/gems/rspec-core-3.1.7/lib/rspec/core/configuration.rb:1105:“加载规范文件”中
from/Users/monteirobrena/.rvm/rubies/ruby-2.2.2/lib/ruby/gems/2.2.0/gems/rspec-core-3.1.7/lib/rspec/core/runner.rb:96:在“设置”中
from/Users/monteirobrena/.rvm/rubies/ruby-2.2.2/lib/ruby/gems/2.2.0/gems/rspec-core-3.1.7/lib/rspec/core/runner.rb:84:in“run”
from/Users/monteirobrena/.rvm/rubies/ruby-2.2.2/lib/ruby/gems/2.2.0/gems/rspec-core-3.1.7/lib/rspec/core/runner.rb:69:in“run”
from/Users/monteirobrena/.rvm/rubies/ruby-2.2.2/lib/ruby/gems/2.2.0/gems/rspec-core-3.1.7/lib/rspec/core/runner.rb:37:in“invoke”
来自/Users/monteirobrena/.rvm/gems/ruby-2.2。2@global/gems/rspec-core-3.1.7/exe/rspec:4:in`'
from/Users/monteirobrena/.rvm/rubies/ruby-2.2.2/bin/rspec:23:in'load'
from/Users/monteirobrena/.rvm/rubies/ruby-2.2.2/bin/rspec:23:in`'
来自/Users/monteirobrena/.rvm/gems/ruby-2.2。2@global/bin/ruby可执行文件挂钩:15:in'eval'
来自/Users/monteirobrena/.rvm/gems/ruby-2.2。2@global/bin/ruby\u可执行文件\u挂钩:15:in`'

有什么想法吗?谢谢。

您收到的弃用警告和建议来自Rails,而不是RSpec或RSpec Rails gem。rspec rails gem实现了
使用事务性装置=
。它没有实现
use\u transactional\u tests=
,因此在进行更改时会收到错误消息


除非rspec rails gem升级为支持新的rails 5功能,否则您需要直接设置rails配置,而从rspec rails 3.8开始,就没有了。

您需要继续使用rspec configure forrails 5 beta中的config.use_transactional_fixtures=true(至少在正式发布之前,不确定rspec团队计划如何支持这一点)。 主分支上已存在修复程序

在主分支上设置rspec gems:

%w[rspec-core rspec-expectations rspec-mocks rspec-rails rspec-support].each do |lib|
    gem lib, git: "https://github.com/rspec/#{lib}.git", branch: 'master'
end

我更新了我的rspec版本,因此我不需要更改我的
使用\u事务性\u fixture
行。在此期间,只有一个测试版:

gem 'rspec', '~> 3.5.0.beta4'
gem 'rspec-rails', '~> 3.5.0.beta4'

你能解释一下在这种情况下我需要删除哪些行以及需要添加哪些行吗?对于那些在2018年找到这篇文章的人:我正在将Rails 4引擎升级到Rails 5.1,为了解决这个错误,我将所有出现的“use_transactional_Fixture”替换为“use_transactional_tests”。除了/spec/Rails_helper.rb中仍然需要的内容之外“使用事务性固定装置”。RSpec测试现已成功运行。RSpec 3.8和2019年——最新建议保持不变——RSpec“使用事务性固定装置”
%w[rspec-core rspec-expectations rspec-mocks rspec-rails rspec-support].each do |lib|
    gem lib, git: "https://github.com/rspec/#{lib}.git", branch: 'master'
end
gem 'rspec', '~> 3.5.0.beta4'
gem 'rspec-rails', '~> 3.5.0.beta4'