#< RSpec :: Core :: Configuration:0x007f7fb3a62b80>的未定义方法`infer

编程入门 行业动态 更新时间:2024-10-11 07:34:17
本文介绍了#< RSpec :: Core :: Configuration:0x007f7fb3a62b80>的未定义方法`infer_base_class_for_anonymous_controllers =' (NoMethodError)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我目前正在参加Hartl教程的第7章,每次我跑步时

I'm currently on Chapter 7 of Hartl's Tutorial, and every time I run

bundle exec rspec spec/

bundle exec rspec spec/

以下结果:

/Users/siciliana/sample_app/spec/spec_helper.rb:31:in `block in <top (required)>': undefined method `infer_base_class_for_anonymous_controllers=' for #<RSpec::Core::Configuration:0x007f7fb3a62b80> (NoMethodError) from /usr/local/rvm/gems/ruby-2.0.0-p0/gems/rspec-core-2.6.4/lib/rspec/core.rb:79:in `configure' from /Users/siciliana/sample_app/spec/spec_helper.rb:11:in `<top (required)>' from /Users/siciliana/sample_app/spec/models/user_spec.rb:12:in `require' from /Users/siciliana/sample_app/spec/models/user_spec.rb:12:in `<top (required)>' from /usr/local/rvm/gems/ruby-2.0.0-p0/gems/rspec-core-2.6.4/lib/rspec/core/configuration.rb:419:in `load' from /usr/local/rvm/gems/ruby-2.0.0-p0/gems/rspec-core-2.6.4/lib/rspec/core/configuration.rb:419:in `block in load_spec_files' from /usr/local/rvm/gems/ruby-2.0.0-p0/gems/rspec-core-2.6.4/lib/rspec/core/configuration.rb:419:in `map' from /usr/local/rvm/gems/ruby-2.0.0-p0/gems/rspec-core-2.6.4/lib/rspec/core/configuration.rb:419:in `load_spec_files' from /usr/local/rvm/gems/ruby-2.0.0-p0/gems/rspec-core-2.6.4/lib/rspec/core/command_line.rb:18:in `run' from /usr/local/rvm/gems/ruby-2.0.0-p0/gems/rspec-core-2.6.4/lib/rspec/core/runner.rb:80:in `run_in_process' from /usr/local/rvm/gems/ruby-2.0.0-p0/gems/rspec-core-2.6.4/lib/rspec/core/runner.rb:69:in `run' from /usr/local/rvm/gems/ruby-2.0.0-p0/gems/rspec-core-2.6.4/lib/rspec/core/runner.rb:11:in `block in autorun'

有人可以向绝对的新手解释这里发生了什么吗?

Can someone please explain what is happening here to an absolute newbie?

spec_helper.rb:

# This file is copied to spec/ when you run 'rails generate rspec:install' ENV["RAILS_ENV"] ||= 'test' require File.expand_path("../../config/environment", __FILE__) require 'rspec/rails' require 'rspec/autorun' # RSpec.configure do |config| # ## Mock Framework # # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line: # # config.mock_with :mocha # config.mock_with :flexmock # config.mock_with :rr # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures config.fixture_path = "#{::Rails.root}/spec/fixtures" # If you're not using ActiveRecord, or you'd prefer not to run each of your # examples within a transaction, remove the following line or assign false # instead of true. config.use_transactional_fixtures = true # If true, the base class of anonymous controllers will be inferred # automatically. This will be the default behavior in future versions of # rspec-rails. config.infer_base_class_for_anonymous_controllers = false # Run specs in random order to surface order dependencies. If you find an # order dependency and want to debug it, you can fix the order by providing # the seed, which is printed after each run. # --seed 1234 config.order = "random" end

推荐答案

我遇到了相同的错误(尽管没有遵循本教程).

I was getting the same error (although not following the tutorial).

我相信此设置需要'rspec/rails'

我的解决方案是移动生产线

My solution was to move the line

config.infer_base_class_for_anonymous_controllers = # whatever

从spec_helper.rb到rails_helper.rb.

更多推荐

#&lt; RSpec :: Core :: Configuration:0x007f7fb3a62b80&gt;的未定义方法`infer

本文发布于:2023-10-27 23:43:57,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1534878.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:未定义   方法   RSpec   Core   amp

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!