"uninitialized constant Cucumber::Rb_Support (NameError)" when 运行 Cucumber for Ruby & Watir

"uninitialized constant Cucumber::Rb_Support (NameError)" when running Cucumber for Ruby & Watir

使用 gem 安装 Ruby、Cucumber 和 Watir 后,出现以下错误:

uninitialized constant Cucumber::Rb_Support (NameError)
W:/Programme/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-2.0.2/lib/cucumber/constantize.rb:41:in `constantize_name'
W:/Programme/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-2.0.2/lib/cucumber/constantize.rb:13:in `block in constantize'
W:/Programme/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-2.0.2/lib/cucumber/constantize.rb:12:in `each'
W:/Programme/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-2.0.2/lib/cucumber/constantize.rb:12:in `constantize'
W:/Programme/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-2.0.2/lib/cucumber/runtime/support_code.rb:87:in `load_programming_language'
W:/Programme/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-2.0.2/lib/cucumber/runtime/support_code.rb:242:in `programming_language_for'
W:/Programme/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-2.0.2/lib/cucumber/runtime/support_code.rb:226:in `load_file'
W:/Programme/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-2.0.2/lib/cucumber/runtime/support_code.rb:97:in `block in load_files!'
W:/Programme/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-2.0.2/lib/cucumber/runtime/support_code.rb:96:in `each'
W:/Programme/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-2.0.2/lib/cucumber/runtime/support_code.rb:96:in `load_files!'
W:/Programme/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-2.0.2/lib/cucumber/runtime.rb:242:in `load_step_definitions'
W:/Programme/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-2.0.2/lib/cucumber/runtime.rb:65:in `run!'
W:/Programme/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-2.0.2/lib/cucumber/cli/main.rb:38:in `execute!'
W:/Programme/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-2.0.2/bin/cucumber:9:in `<top (required)>'
W:/Programme/Ruby193/bin/cucumber:23:in `load'
W:/Programme/Ruby193/bin/cucumber:23:in `<main>'**

有人知道为什么这不起作用吗? 我从 github 页面复制了确切的示例。

我终于自己找到了解决办法。

如果有人遇到这个问题,很可能是 Ruby 版本与 Gherkin/Cucumber and/or Watir 不兼容造成的。

虽然 Ruby 有更新版本,但在我的 Windows 7 (Win64) 机器上运行的唯一版本是以下组合:

  • Ruby:rubyinstaller-2.0.0-p645.exe
  • 开发工具包:DevKit-mingw64-32-4.7.2-20130224-1151-sfx.exe

然后我按照 http://www.spritecloud.com/2015/04/complete-setup-guide-for-ruby-cucumber-and-watir-on-windows/

上的安装说明进行操作

我使用了 https://github.com/spriteCloud/cucumber-watir-example 上的示例,效果很好。

遵循此操作并没有产生任何错误,并且该示例有效。

祝你好运!