Özgün Koyun Özgün Koyun

Dealing with Cucumber errors

  ruby testing

To fix the following error:

undefined method `fork=' for #<Cucumber::Rake::Task:0xb770bab8>

You need to upgrade cucumber, rspec and rspec-rails.

$ gem install cucumber
$ gem install rspec
$ gem install rspec-rails

If you run into the following error:

cucumber database is not configured (ActiveRecord::AdapterNotSpecified)

Then you should run the cucumber script to update your database.yml file:

$ script/generate cucumber

If are getting the following error after your run “cucumber features”

no such file to load -- spec/test/unit

Then you may need to install or upgrade “hoe” gem, U’ not sure though, but it worked for me.

$ gem install hoe

Can’t you install “factory girl” with the following command?

$ gem install thoughtbot-factory_girl

Why not adding Github’s gem archive to your gem source list?

$ gem sources -a http://gems.github.com
$ gem install thoughtbot-factory_girl

You upgraded to cucumber 0.3.103 and webrat 0.5.3, you run your features and get the following error:

undefined method `use_transactional_fixtures' for Cucumber::Rails:Module (NoMethodError)

It is easy to fix. Replace



Cucumber::Rails::World.use_transactional_fixtures = true

You fixed the error above, but this time you see the following error:

undefined method `bypass_rescue' for Cucumber::Rails:Module (NoMethodError)




ActionController::Base.allow_rescue = false

By the way, why don’t you just create a new features/support/env.rb by running the following command?

$ ./script/generate cucumber

So, you upgraded to cucumber 0.3.103 and you tried to run a feature with “—tags” or “-t” parameter like the following:

$ cucumber -r features/ -t focus features/feedback.feature

And you get the following error:

0 scenarios
0 steps
You have a nil object when you didn't expect it!
You might have expected an instance of ActiveRecord::Base.
The error occurred while evaluating nil.[] (NoMethodError)
/usr/lib/ruby/gems/1.8/gems/cucumber-0.3.103/bin/../lib/cucumber/formatter/console.rb:132:in `print_tag_limit_warnings'
/usr/lib/ruby/gems/1.8/gems/cucumber-0.3.103/bin/../lib/cucumber/formatter/console.rb:130:in `each'
/usr/lib/ruby/gems/1.8/gems/cucumber-0.3.103/bin/../lib/cucumber/formatter/console.rb:130:in `print_tag_limit_warnings'
/usr/lib/ruby/gems/1.8/gems/cucumber-0.3.103/bin/../lib/cucumber/formatter/pretty.rb:232:in `print_summary'
/usr/lib/ruby/gems/1.8/gems/cucumber-0.3.103/bin/../lib/cucumber/formatter/pretty.rb:27:in `after_features'
/usr/lib/ruby/gems/1.8/gems/cucumber-0.3.103/bin/../lib/cucumber/ast/tree_walker.rb:170:in `__send__'
/usr/lib/ruby/gems/1.8/gems/cucumber-0.3.103/bin/../lib/cucumber/ast/tree_walker.rb:170:in `send_to_all'
/usr/lib/ruby/gems/1.8/gems/cucumber-0.3.103/bin/../lib/cucumber/ast/tree_walker.rb:168:in `each'
/usr/lib/ruby/gems/1.8/gems/cucumber-0.3.103/bin/../lib/cucumber/ast/tree_walker.rb:168:in `send_to_all'
/usr/lib/ruby/gems/1.8/gems/cucumber-0.3.103/bin/../lib/cucumber/ast/tree_walker.rb:164:in `broadcast'
/usr/lib/ruby/gems/1.8/gems/cucumber-0.3.103/bin/../lib/cucumber/ast/tree_walker.rb:14:in `visit_features'
/usr/lib/ruby/gems/1.8/gems/cucumber-0.3.103/bin/../lib/cucumber/cli/main.rb:55:in `execute!'
/usr/lib/ruby/gems/1.8/gems/cucumber-0.3.103/bin/../lib/cucumber/cli/main.rb:24:in `execute'
/usr/bin/cucumber:19:in `load'

It is obvious that none of your scenarios run, why? Because as “aslakhellesoy” said: “you have to use -t @focus since 0.3.102”. But don’t worry, he also added that he was going to hack the code to display you a friendly message if you try to use tags without “@” symbol. So, to get rid of the error above, run your tagged feature like this:

$ cucumber -r features/ -t @focus features/feedback.feature

aslakhellesoy kept his promise and updated Cucumber to display a friendly message in case you use ‘-t’ parameter withouth ‘@’ symbol. Related commit can be found here