"未初始化的常量Cucumber :: Rb_Support(NameError)"运行Cucumber for Ruby&的Watir

时间:2015-08-14 11:38:42

标签: ruby gem cucumber 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页面复制了确切的例子。

1 个答案:

答案 0 :(得分:1)

我终于找到了解决方案。

如果有人遇到此问题,很可能是由与Gherkin / Cucumber和/或Watir不兼容的Ruby版本引起的。

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

  • Ruby:rubyinstaller-2.0.0-p645.exe
  • DevKit: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上有效的例子。

在此之后没有产生任何错误,并且该示例有效。

祝你好运!