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

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

添加

group :test do
  gem 'cucumber'
end

到我的Gemfile。

运行bundle install

随后通过rails generate cucumber:install

当没有特征时,黄瓜似乎按预期运行。

但是,当我添加一个功能文件并运行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: parse' /Users/purinkle/.rvm/gems/ruby-1.9.3-p286@radfords/gems/cucumber-1.2.1/lib/cucumber/runtime/features_loader.rb:28:in block in load'/ Users /purinkle/.rvm/gems/ruby-1.9.3-p286@radfords/gems/cucumber-1.2.1/lib/cucumber/runtime/features_loader.rb:26:在each' /Users/purinkle/.rvm/gems/ruby-1.9.3-p286@radfords/gems/cucumber-1.2.1/lib/cucumber/runtime/features_loader.rb:26:in加载'/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:在run!' /Users/purinkle/.rvm/gems/ruby-1.9.3-p286@radfords/gems/cucumber-1.2.1/lib/cucumber/cli/main.rb:43:in run!' /Users/purinkle/.rvm/gems/ruby-1.9.3-p286@radfords/gems/cucumber-1.2.1/lib/cucumber/cli/main.rb:43:in execute!' /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 :23:in'


你可能有其他一些实现Gherkin宝石。

例如,如果您安装了spinach ,会产生冲突:当cucumber需要Gherkin ,它会从spinach宝石中取出,而不是从小gherkin中取出

CucumberGherkin::Parser是一个带有Parser类的模块[1]。

Spinach使用gherkin-ruby [2],它以不同的方式实现整个事情,但使用相同的名称[3](实施不善的IMO)。

尝试卸载spinach (从你的Gemfile删除它,并且bundle update应该足够了),或者你可能会导致名称冲突的任何东西。

  • [1] https://github.com/cucumber/gherkin/blob/master/lib/gherkin/parser/parser.rb#L14
  • [2] https://github.com/codegram/gherkin-ruby
  • [3] https://github.com/codegram/gherkin-ruby/blob/master/lib/gherkin/parser/parser.rb#L13
  • 链接地址: http://www.djcxy.com/p/38761.html

    上一篇: uninitialized constant Gherkin::Parser::Parser (NameError)

    下一篇: ruby on rails mac x os lion run server LoadError