3
votes

I am trying to install cucumber on rails 2.3.11 (gem -v = 1.6.2) with the following Gemfile

group :test do
  gem 'fabrication'
  gem 'cucumber'
  gem 'cucumber-rails'
end

Bundle install is successful, but I can't find the 'cucumber' generator.

bundle exec script/generate cucumber
/Users/Tim/.rvm/gems/ree-1.8.7-2011.03@new_horizons/gems/rails-2.3.11/lib/rails_generator/lookup.rb:212:Warning: Gem::cache is deprecated and will be removed on or after August 2011.  Use Gem::source_index.
/Users/Tim/.rvm/gems/ree-1.8.7-2011.03@new_horizons/gems/rails-2.3.11/lib/rails_generator/lookup.rb:234:Warning: Gem::cache is deprecated and will be removed on or after August 2011.  Use Gem::source_index.
Couldn't find 'cucumber' generator

Any thoughts greatly appreciated. I am running: ruby 1.8.7 (2011-02-18 patchlevel 334) [i686-darwin10.7.0], MBARI 0x6770, Ruby Enterprise Edition 2011.03

tim

3

3 Answers

2
votes

When you're running the generators they are actually running in the development environment, not test. Therefore these dependencies won't be loaded. Put them in a group like this instead:

group :development, :test do
  gem 'cucumber-rails'
  ...
end

Secondly, you don't need to specify cucumber as well as cucumber-rails, as the cucumber gem is a dependency of the cucumber-rails gem and will be automatically included.

2
votes

According to the cucumber-rails documentation, the generate command should be cucumber:install, not just cucumber. It also says it's for Rails 3, not sure if that's true though.

1
votes

First thought is to upgrade your ruby version. In the long run that will solve more problems as newer gems are becoming dependent on ruby 1.9.2. Install RVM and use that to manage your different ruby versions and gem sets.

The second thing is to do what the error is saying.

gem sources

That will show you which souces and gems you have. Something like this:

*** CURRENT SOURCES ***

http://rubygems.org/

If you know where you specific gem is being hosted then you can add those sources to the top of your bundler file. Usually all you need is http://rubygems.org/.

But you can also add it directly to your sources with this:

gem sources:add `http://rubygems.org/`