gpt4 book ai didi

rspec - # 的未定义方法 `use_transactional_tests='(NoMethodError)

转载 作者:行者123 更新时间:2023-12-04 14:11:16 24 4
gpt4 key购买 nike

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

undefined method `use_transactional_tests=' for #<RSpec::Core::Configuration:0x007fccf515e338> (NoMethodError)

rails_helper.rb我通常使用它并且一切正常:
config.use_transactional_fixtures = true

但我收到了这个警告:
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)

所以,我改变了我的 rails_helper.rb使用新方法:
config.use_transactional_tests = true

现在我收到了这个错误:
/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>'

有任何想法吗?谢谢你。

最佳答案

您收到的弃用警告和建议来自 Rails,而不是 RSpec 或 rspec-rails gem。 rspec-rails gem 实现 use_transactional_fixtures= and turns around and calls the same method in Rails .它没有实现 use_transactional_tests= ,因此您在进行更改时会收到该错误消息。

除非 rspec-rails gem 升级以支持新的 Rails 5 功能,否则您需要直接设置 Rails 配置 - 从 rspec-rails 3.8 开始,它不需要。

关于rspec - #<RSpec::Core::Configuration:0x007fccf515e338> 的未定义方法 `use_transactional_tests='(NoMethodError),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31880390/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com