未初始化的常量Gherkin :: Parser :: Parser(NameError)

时间:2012-10-14 06:20:14

标签: ruby-on-rails cucumber

我刚刚通过以下步骤将Cucumber添加到我的Rails应用程序中:

添加

group :test do
  gem 'cucumber'
end

到我的Gemfile。

正在运行bundle install

后跟rails generate cucumber:install

当没有任何功能时,Cucumber似乎按预期运行。

但是当我添加一个功能文件并运行bundle exec cucumber时,我得到以下内容

  

未初始化的常量Gherkin :: Parser :: Parser(NameError)   /Users/purinkle/.rvm/gems/ruby-1.9.3-p286@radfords/gems/cucumber-1.2.1/lib/cucumber/feature_file.rb:34:in parse' /Users/purinkle/.rvm/gems/ruby-1.9.3-p286@radfords/gems/cucumber-1.2.1/lib/cucumber/runtime/features_loader.rb:28:in阻止加载'   /Users/purinkle/.rvm/gems/ruby-1.9.3-p286@radfords/gems/cucumber-1.2.1/lib/cucumber/runtime/features_loader.rb:26:in each' /Users/purinkle/.rvm/gems/ruby-1.9.3-p286@radfords/gems/cucumber-1.2.1/lib/cucumber/runtime/features_loader.rb:26:in load'   /Users/purinkle/.rvm/gems/ruby-1.9.3-p286@radfords/gems/cucumber-1.2.1/lib/cucumber/runtime/features_loader.rb:14:in features' /Users/purinkle/.rvm/gems/ruby-1.9.3-p286@radfords/gems/cucumber-1.2.1/lib/cucumber/runtime.rb:170:in features'   /Users/purinkle/.rvm/gems/ruby-1.9.3-p286@radfords/gems/cucumber-1.2.1/lib/cucumber/runtime.rb:46:in run!' /Users/purinkle/.rvm/gems/ruby-1.9.3-p286@radfords/gems/cucumber-1.2.1/lib/cucumber/cli/main.rb:43:in执行!'   /Users/purinkle/.rvm/gems/ruby-1.9.3-p286@radfords/gems/cucumber-1.2.1/lib/cucumber/cli/main.rb:20:in execute' /Users/purinkle/.rvm/gems/ruby-1.9.3-p286@radfords/gems/cucumber-1.2.1/bin/cucumber:14:in'   /Users/purinkle/.rvm/gems/ruby-1.9.3-p286@radfords/bin/cucumber:23:in load' /Users/purinkle/.rvm/gems/ruby-1.9.3-p286@radfords/bin/cucumber:23:in'

1 个答案:

答案 0 :(得分:1)

您可能还有其他一些实现Gherkin的宝石。

例如,如果您安装了spinach,则会产生冲突:当cucumber需要Gherkin时,它将从spinach gem而非{来自{ {1}}

gherkin的{​​{1}}是一个Cucumber类的模块[1]。

Gherkin::Parser使用Parser [2],它以不同的方式实现整个事情,但使用相同的名称[3](执行不佳的IMO)。

尝试卸载Spinach(从gherkin-ruby删除它,spinach就足够了)或任何可能导致名称冲突的内容。