Monday, June 13, 2011

The importance of specifying gem versions in your Gemfile

I'm starting to integrate cucumber into a Rails 3 application.  Specifically, I added 'cucumber-rails' to my Gemfile, but I kept getting this error when I ran "rake cucumber":
undefined method `click' for class `Capybara::Driver::RackTest::Node' (NameError)
Turns out it is very important to specify gem versions in your Gemfile.  I hadn't specified a version for cucumber-rails, so consequently, abstruse incompatibilities emerged.

All I had to do was change gem 'cucumber-rails' to gem 'cucumber-rails', '>= 0.5.1'

This is what my Gemfile currently looks like:

source 'http://rubygems.org'
gem 'rails', '3.0.3'
gem 'authlogic', :git => "git://github.com/radar/authlogic.git"
gem 'cancan'
gem 'paperclip', :git => "git://github.com/thoughtbot/paperclip.git"
gem 'acts_as_list', :git => "https://github.com/haihappen/acts_as_list.git"
gem "will_paginate", "~> 3.0.pre2"
gem 'dynamic_form'
gem 'mysql2'
gem 'nokogiri'
gem 'capistrano' # we deploy with capistrano

group :development, :test do
 gem 'sqlite3-ruby', :require => 'sqlite3'
 gem 'shoulda'
 gem 'cucumber-rails', '>= 0.5.1' # important to specify this version
 gem 'database_cleaner'
 gem 'capybara'
 gem "rspec-rails", ">= 2.0.0"
end

# These typically shouldn't be for production, but I need it for seed data
gem 'factory_girl_rails'
gem 'forgery'

*Also, it's important to re-run rails generate cucumber:install after a change related to cucumber in your Gemfile.

No comments:

Post a Comment

Please be considerate in what you say.