1

我刚刚通过以下步骤将 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:在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:inload'/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:infeatures' /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在执行!/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'

4

1 回答 1

1

您可能还有其他一些实现Gherkin.

spinach例如,如果您已安装,这将产生冲突:当cucumberrequires时Gherkin,它将从spinachgem 中提取而不是从gherkin

Cucumber'sGherkin::Parser是一个包含一个Parser类的模块 [1]。

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

尝试卸载spinach(从您的Gemfile和 a中删除它就bundle update足够了)或任何可能导致名称冲突的东西。

于 2012-10-31T13:19:52.410 回答