cucumber/cucumber — Issue #158: cucumber v 1.1.0 fails when used on a rails project with model named Usage
Author: jarl-dk
Created: 2011-10-20 12:58:09+00:00
State: open

On a rails project I use cucumber. We have a model named Usage.

When I run

cucumber -f usage
it fails because constantize returns the constanct `Usage` and without the constant being fully qualified, it evaluates to the one that derives from ActiveRecord. The result is

$ bundle exec cucumber -f usage
Using the default profile...
/home/jarl/.rvm/gems/ruby-1.9.2-p290/gems/rack-1.3.4/lib/rack/backports/uri/common_192.rb:53: warning: already initialized constant WFKV_
wrong number of arguments (3 for 2)
Error creating formatter: usage (ArgumentError)
/home/jarl/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.1.1/lib/active_record/base.rb:1549:in `initialize'
/home/jarl/.rvm/gems/ruby-1.9.2-p290/gems/cucumber-1.1.0/lib/cucumber/cli/configuration.rb:168:in `new'
/home/jarl/.rvm/gems/ruby-1.9.2-p290/gems/cucumber-1.1.0/lib/cucumber/cli/configuration.rb:168:in `block in formatters'
/home/jarl/.rvm/gems/ruby-1.9.2-p290/gems/cucumber-1.1.0/lib/cucumber/cli/configuration.rb:163:in `map'
/home/jarl/.rvm/gems/ruby-1.9.2-p290/gems/cucumber-1.1.0/lib/cucumber/cli/configuration.rb:163:in `formatters'
/home/jarl/.rvm/gems/ruby-1.9.2-p290/gems/cucumber-1.1.0/lib/cucumber/cli/configuration.rb:68:in `build_tree_walker'
/home/jarl/.rvm/gems/ruby-1.9.2-p290/gems/cucumber-1.1.0/lib/cucumber/runtime.rb:42:in `run!'
/home/jarl/.rvm/gems/ruby-1.9.2-p290/gems/cucumber-1.1.0/lib/cucumber/cli/main.rb:43:in `execute!'
/home/jarl/.rvm/gems/ruby-1.9.2-p290/gems/cucumber-1.1.0/lib/cucumber/cli/main.rb:20:in `execute'
/home/jarl/.rvm/gems/ruby-1.9.2-p290/gems/cucumber-1.1.0/bin/cucumber:14:in `'
/home/jarl/.rvm/gems/ruby-1.9.2-p290/bin/cucumber:19:in `load'
/home/jarl/.rvm/gems/ruby-1.9.2-p290/bin/cucumber:19:in `

'

One resolution is to make constantize return the fully qualified constant, I will provide a patch.

You can reproduce by creating a rails project and use cucumber-rails and create a model named Usage, then run

bundle exec cucumber -f usage