rspec 获得 "undefined method `build_rb_world_factory' for nil"
rspec gets "undefined method `build_rb_world_factory' for nil"
我正在将 Rails 3.2 应用更新到 Ruby 2.2.2。我已将 Rails 版本升级到 3.2.22,这是 Ruby 2.2.2 所必需的。这相对顺利,但促使 Cucumber 更新,从 1.2.1 到 1.3.20。 (我不记得细节,因为那是之前几次失败的努力,但我认为我的功能是通过的,但在我这样做之前退出 false。)
现在 Cucumber 的功能 运行 很好(尽管有大量不相关的 Ruby 2.2.2 警告),但 rspec 没有。具体来说,当我 运行 rake spec
我得到这个错误:
/path/to/gems/cucumber-1.3.20/lib/cucumber/rb_support/rb_dsl.rb:15:in `build_rb_world_factory': undefined method `build_rb_world_factory' for nil:NilClass (NoMethodError)
堆栈跟踪通过 Capybara(2.4.4,由于其他原因固定)、ActiveSupport 和 Bundler 返回到 rspec-core。
我所有试图找到类似问题的搜索都指向代码,因为看起来这个方法名称唯一存在的地方就是在代码中。
为什么我在 运行 宁 rspec 时从 Capybara/Cucumber 收到此错误?我该如何解决?
ETA:堆栈跟踪,路径压缩了一点:
/path/to/gems/cucumber-1.3.20/lib/cucumber/rb_support/rb_dsl.rb:15:in `build_rb_world_factory': undefined method `build_rb_world_factory' for nil:NilClass (NoMethodError)
from /path/to/gems/cucumber-1.3.20/lib/cucumber/rb_support/rb_dsl.rb:50:in `World'
from /path/to/gems/capybara-2.4.4/lib/capybara/cucumber.rb:4:in `<top (required)>'
from /path/to/gems/activesupport-3.2.22/lib/active_support/dependencies.rb:251:in `require'
from /path/to/gems/activesupport-3.2.22/lib/active_support/dependencies.rb:251:in `block in require'
from /path/to/gems/activesupport-3.2.22/lib/active_support/dependencies.rb:236:in `load_dependency'
from /path/to/gems/activesupport-3.2.22/lib/active_support/dependencies.rb:251:in `require'
from /path/to/gems/capybara-screenshot-0.2.2/lib/capybara-screenshot.rb:96:in `<top (required)>'
from /path/to/gems/bundler-1.10.6/lib/bundler/runtime.rb:76:in `require'
from /path/to/gems/bundler-1.10.6/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
from /path/to/gems/bundler-1.10.6/lib/bundler/runtime.rb:72:in `each'
from /path/to/gems/bundler-1.10.6/lib/bundler/runtime.rb:72:in `block in require'
from /path/to/gems/bundler-1.10.6/lib/bundler/runtime.rb:61:in `each'
from /path/to/gems/bundler-1.10.6/lib/bundler/runtime.rb:61:in `require'
from /path/to/gems/bundler-1.10.6/lib/bundler.rb:134:in `require'
from /path/to/app/config/application.rb:13:in `<top (required)>'
from /path/to/app/config/environment.rb:2:in `require'
from /path/to/app/config/environment.rb:2:in `<top (required)>'
from /path/to/app/spec/spec_helper.rb:10:in `require'
from /path/to/app/spec/spec_helper.rb:10:in `<top (required)>'
from /path/to/app/spec/controllers/academic_years_controller_spec.rb:1:in `require'
from /path/to/app/spec/controllers/academic_years_controller_spec.rb:1:in `<top (required)>'
from /path/to/gems/rspec-core-3.2.3/lib/rspec/core/configuration.rb:1226:in `load'
from /path/to/gems/rspec-core-3.2.3/lib/rspec/core/configuration.rb:1226:in `block in load_spec_files'
from /path/to/gems/rspec-core-3.2.3/lib/rspec/core/configuration.rb:1224:in `each'
from /path/to/gems/rspec-core-3.2.3/lib/rspec/core/configuration.rb:1224:in `load_spec_files'
from /path/to/gems/rspec-core-3.2.3/lib/rspec/core/runner.rb:97:in `setup'
from /path/to/gems/rspec-core-3.2.3/lib/rspec/core/runner.rb:85:in `run'
from /path/to/gems/rspec-core-3.2.3/lib/rspec/core/runner.rb:70:in `run'
from /path/to/gems/rspec-core-3.2.3/lib/rspec/core/runner.rb:38:in `invoke'
from /path/to/gems/rspec-core-3.2.3/exe/rspec:4:in `<main>'
/path/to/ruby/ruby-2.2.2/bin/ruby -I/path/to/gems/rspec-core-3.2.3/lib:/path/to/gems/rspec-support-3.2.2/lib /path/to/gems/rspec-core-3.2.3/exe/rspec --pattern spec/\*\*\{,/\*/\*\*\}/\*_spec.rb failed
我的直觉是有一个配置文件需要在某处重建。
来自您的堆栈跟踪 - 水豚屏幕截图 gem 需要 capybara/cucumber 即使您 运行 规格没有使用黄瓜。这意味着 World 是从 capybara/cucumber 针对未初始化的黄瓜调用的,并给出了错误。您使用的 capybara-screenshot 版本真的很旧,需要 capybara/cucumber 的代码已被删除,因此您可能应该更新您使用的 capybara-screenshot 版本,并添加
require 'capybara/cucumber'
require 'capybara-screenshot/cucumber'
到您的 env.rb 或其他黄瓜支持文件
我正在将 Rails 3.2 应用更新到 Ruby 2.2.2。我已将 Rails 版本升级到 3.2.22,这是 Ruby 2.2.2 所必需的。这相对顺利,但促使 Cucumber 更新,从 1.2.1 到 1.3.20。 (我不记得细节,因为那是之前几次失败的努力,但我认为我的功能是通过的,但在我这样做之前退出 false。)
现在 Cucumber 的功能 运行 很好(尽管有大量不相关的 Ruby 2.2.2 警告),但 rspec 没有。具体来说,当我 运行 rake spec
我得到这个错误:
/path/to/gems/cucumber-1.3.20/lib/cucumber/rb_support/rb_dsl.rb:15:in `build_rb_world_factory': undefined method `build_rb_world_factory' for nil:NilClass (NoMethodError)
堆栈跟踪通过 Capybara(2.4.4,由于其他原因固定)、ActiveSupport 和 Bundler 返回到 rspec-core。
我所有试图找到类似问题的搜索都指向代码,因为看起来这个方法名称唯一存在的地方就是在代码中。
为什么我在 运行 宁 rspec 时从 Capybara/Cucumber 收到此错误?我该如何解决?
ETA:堆栈跟踪,路径压缩了一点:
/path/to/gems/cucumber-1.3.20/lib/cucumber/rb_support/rb_dsl.rb:15:in `build_rb_world_factory': undefined method `build_rb_world_factory' for nil:NilClass (NoMethodError)
from /path/to/gems/cucumber-1.3.20/lib/cucumber/rb_support/rb_dsl.rb:50:in `World'
from /path/to/gems/capybara-2.4.4/lib/capybara/cucumber.rb:4:in `<top (required)>'
from /path/to/gems/activesupport-3.2.22/lib/active_support/dependencies.rb:251:in `require'
from /path/to/gems/activesupport-3.2.22/lib/active_support/dependencies.rb:251:in `block in require'
from /path/to/gems/activesupport-3.2.22/lib/active_support/dependencies.rb:236:in `load_dependency'
from /path/to/gems/activesupport-3.2.22/lib/active_support/dependencies.rb:251:in `require'
from /path/to/gems/capybara-screenshot-0.2.2/lib/capybara-screenshot.rb:96:in `<top (required)>'
from /path/to/gems/bundler-1.10.6/lib/bundler/runtime.rb:76:in `require'
from /path/to/gems/bundler-1.10.6/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
from /path/to/gems/bundler-1.10.6/lib/bundler/runtime.rb:72:in `each'
from /path/to/gems/bundler-1.10.6/lib/bundler/runtime.rb:72:in `block in require'
from /path/to/gems/bundler-1.10.6/lib/bundler/runtime.rb:61:in `each'
from /path/to/gems/bundler-1.10.6/lib/bundler/runtime.rb:61:in `require'
from /path/to/gems/bundler-1.10.6/lib/bundler.rb:134:in `require'
from /path/to/app/config/application.rb:13:in `<top (required)>'
from /path/to/app/config/environment.rb:2:in `require'
from /path/to/app/config/environment.rb:2:in `<top (required)>'
from /path/to/app/spec/spec_helper.rb:10:in `require'
from /path/to/app/spec/spec_helper.rb:10:in `<top (required)>'
from /path/to/app/spec/controllers/academic_years_controller_spec.rb:1:in `require'
from /path/to/app/spec/controllers/academic_years_controller_spec.rb:1:in `<top (required)>'
from /path/to/gems/rspec-core-3.2.3/lib/rspec/core/configuration.rb:1226:in `load'
from /path/to/gems/rspec-core-3.2.3/lib/rspec/core/configuration.rb:1226:in `block in load_spec_files'
from /path/to/gems/rspec-core-3.2.3/lib/rspec/core/configuration.rb:1224:in `each'
from /path/to/gems/rspec-core-3.2.3/lib/rspec/core/configuration.rb:1224:in `load_spec_files'
from /path/to/gems/rspec-core-3.2.3/lib/rspec/core/runner.rb:97:in `setup'
from /path/to/gems/rspec-core-3.2.3/lib/rspec/core/runner.rb:85:in `run'
from /path/to/gems/rspec-core-3.2.3/lib/rspec/core/runner.rb:70:in `run'
from /path/to/gems/rspec-core-3.2.3/lib/rspec/core/runner.rb:38:in `invoke'
from /path/to/gems/rspec-core-3.2.3/exe/rspec:4:in `<main>'
/path/to/ruby/ruby-2.2.2/bin/ruby -I/path/to/gems/rspec-core-3.2.3/lib:/path/to/gems/rspec-support-3.2.2/lib /path/to/gems/rspec-core-3.2.3/exe/rspec --pattern spec/\*\*\{,/\*/\*\*\}/\*_spec.rb failed
我的直觉是有一个配置文件需要在某处重建。
来自您的堆栈跟踪 - 水豚屏幕截图 gem 需要 capybara/cucumber 即使您 运行 规格没有使用黄瓜。这意味着 World 是从 capybara/cucumber 针对未初始化的黄瓜调用的,并给出了错误。您使用的 capybara-screenshot 版本真的很旧,需要 capybara/cucumber 的代码已被删除,因此您可能应该更新您使用的 capybara-screenshot 版本,并添加
require 'capybara/cucumber'
require 'capybara-screenshot/cucumber'
到您的 env.rb 或其他黄瓜支持文件