uninitialized constant Gherkin::Parser::Parser (NameError)
I have just added Cucumber to my Rails app via the following steps:
Adding
group :test do
gem 'cucumber'
end
to my Gemfile.
Running bundle install
Followed by rails generate cucumber:install
When there are no features, Cucumber seems to run as expected.
But when I add a feature file and run bundle exec cucumber
I get the following
uninitialized constant 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
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: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
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
'
You probably have some other gem that implements Gherkin
.
If you have spinach
installed, for example, that will create a conflict: when cucumber
requires Gherkin
, it will pull from the spinach
gem instead of from gherkin
Cucumber
's Gherkin::Parser
is a module with a Parser
class in it [1].
Spinach
uses gherkin-ruby
[2], which implements the whole thing in a different way, but using the same names [3] (poor implementation IMO).
Try uninstalling spinach
(removing it from your Gemfile
and a bundle update
should be enough) or whatever you have that might be causing a name clash.