我刚刚通过以下步骤将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:ineach' /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:infeatures' /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:inrun!' /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:inexecute' /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:inload' /Users/purinkle/.rvm/gems/ruby-1.9.3-p286@radfords/bin/cucumber:23:in
'
答案 0 :(得分:1)
您可能还有其他一些实现Gherkin
的宝石。
例如,如果您安装了spinach
,则会产生冲突:当cucumber
需要Gherkin
时,它将从spinach
gem而非{来自{ {1}}
gherkin
的{{1}}是一个Cucumber
类的模块[1]。
Gherkin::Parser
使用Parser
[2],它以不同的方式实现整个事情,但使用相同的名称[3](执行不佳的IMO)。
尝试卸载Spinach
(从gherkin-ruby
删除它,spinach
就足够了)或任何可能导致名称冲突的内容。