我正在将Rails 3.2应用程序更新为Ruby 2.2.2。我已经将Rails版本提升到3.2.22,这对Ruby 2.2.2来说是必要的。这相当不错,但促使黄瓜更新,从1.2.1升至1.3.20。 (我不记得细节,因为那是几次失败的努力,但我认为我的功能正在通过,但在我这样做之前就退出了假。)
现在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
我的预感是,有一个配置文件需要在某处重建。
答案 0 :(得分:1)
从你的堆栈追踪 - capybara-screenshot宝石需要水豚/黄瓜,即使你正在运行不使用黄瓜的规格。这意味着从水豚/黄瓜对未经初始化的黄瓜调用世界,并给出错误。你正在使用的capybara-screenshot版本真的很旧,而且需要使用水豚/黄瓜的代码已被删除,所以你应该更新你正在使用的capybara-screenshot的版本,并添加
require 'capybara/cucumber'
require 'capybara-screenshot/cucumber'
到您的env.rb或其他黄瓜支持文件