Cucumber-Rails 0.4.0 does not work with Rails 2.3.11 #110

Closed
cgriego opened this Issue Mar 21, 2011 · 22 comments
@cgriego
  1. Install generator fails
    1. driver is undefined
    2. framework is undefined
    3. rails2? is returning nil instead of a truthy value
  2. cucumber/rails fails on require 'rails' with a load error.
@morgoth

I have same problem with new cucumber and rails 2.3.11
When I run bundle exec cucumber:
uninitialized constant Rack::Test (NameError)
When I run script/generate cucumber:
undefined local variable or methoddriver' for #CucumberGenerator:0x7d802f0`

@aslakhellesoy
Cucumber member

This shouldn't be too hard to fix actually, it worked not long ago. The root cause of the breakage is lack of a proper test environment for Rails 2.3 - it's a little tricky to make that coexist with a test environment for Rails 3.

For testing Rails 2 I propose the following:

Change to a clean gemset

rvm gemset create cucumber-rails-2

(By default, if you're using rvm - and you should - rvm sets the gemset to cucumber when you cd into cucumber-rails)

Install Rails2 gems

The current Gemfile declares Rails 3 gems. We could change it like so:

if ENV['RAILS2']
  # Install Rails 2 gems and other deps
else
  # Install Rails 3 gems (what's currently in the Gemfile)
end

Fix the step definitions

The step definitions used by Cucumber-Rails hard-code Rails3 commands. By using the same environment variable in the step above, we could do things the Rails 2 way if that variable is set

Use tags and profiles

Some of the scenarios may be Rails2 or Rails 3 only. They should be tagged with @rails2 and @rails3. We should have a profile for each.

Summing up

Testing with Rails2 would look like this:

cd cucumber-rails
rvm use cucumber-rails-2
RAILS2=true rake

Testing with Rails3 would look like this (that's how it currently works):

cd cucumber-rails
rake
@yoka

First of all, I'm also having this problem.. I tried to run rake cucumber and got this:
uninitialized constant Rack::Test (NameError)

Then I google a bit and try to run: script/generate cucumber:
undefined local variable or method `driver' for #CucumberGenerator:0x102e30e88

I'm really sorry, but I do not understand your instructions at all. How come creating a new gemset helps with this issue?

I do not have rails3 coexisting with rails2 because I'm using different ruby version for that anyways, so I can't see any reason for creating new gemset for my rails2 ruby environment.. Or am I missing something here..?

@aslakhellesoy
Cucumber member

These steps are for a developer of Cucumber-Rails (me, contributors) - not users of Cucumber-Rails.

Before I can even start fixing Rails2-related bugs I need to be able to run the features on both Rails3 and Rails2.

The Cucumber-Rails project has its own Cucumber features. They are currently designed to work with Rails3 only. The gems needed to run the cucumber suite are in Gemfile.

Once a Cucumber-Rails developer has run gem install he'll have rails3 in the current gemset. This means he can't also run the features for Rails2 (Installing rails2 in the same gemset won't work - rails2 and rails3 can't coexist in the same gemset). That's why a new gemset is needed to be able to run the features agains Rails2.

Once this is in place we can start adapting the features (and fix the bugs) so it works with Rails2 too.

@yoka

Oh okay now I got it. :) Thank you for your input. I'll take a look if I can assist with these issues. Also thank you for the great project!

@morgoth

After digging a while, main problem is with line:
require 'rails' in lib/cucumber/rails.rb file.
There is no such file in rails2.
After commenting this line out and having env.rb file: https://gist.github.com/883244
cucumber can be run.
I didn't have time yet to resolve this problem in nice way.

@schmidt

That URL contains some spaces. This one should work:

https://gist.github.com/883244

@sethfuller

Another workaround is to specify Cucumber Rails 0.3.2 (or other version prior to 0.4.0) in your Gemfile like this:

gem 'cucumber-rails', '0.3.2'

@waugh

Tried installing 0.3.2 but rubygems can't find it.
$ gem install cucumber-rails -r 0.3.2 --no-rdoc --no-ri
Successfully installed cucumber-rails-0.4.1
ERROR: could not find gem 0.3.2 locally or in a repository
1 gem installed
[on edit] oops, I forgot to mention what version I have of everything.
$ ruby --version
ruby 1.8.7 (2008-08-11 patchlevel 72) [i686-linux]
$ gem --version
1.3.6

@aslakhellesoy
Cucumber member
@agibralter

Would it make sense to just move the require 'rails' line into the else part of if Rails.version.to_f < 3.0?

@aslakhellesoy
Cucumber member

I have decided to not longer support Rails 2.x in future versions of Cucumber-Rails. Too much work.

@matiasleidemer

Since there is no longer support on Rails 2.3.x it would be nice to update the cucumber wiki. The instructions for configuring Cucumber with Rails don't specify any version requirements on Rails 2.3.x. I almost gone crazy trying to set the right env on my 2.3.X rails app.

@aslakhellesoy
Cucumber member

Cucumber-Rails' README specify that it only works with Rails3. I have updated the wiki as well.

@jerrod

https://github.com/cucumber/cucumber/wiki/Ruby-on-Rails

The wiki still recommends using 0.4.1 - specifically:

Rails 2.x
If you are on Rails 2.x you have to use an older version of Cucumber-Rails. We recommend using Cucumber-Rails 0.3.2 or 0.4.1 with Cucumber 0.10.3.
@@@

@philrosenstein

It is true, there should be no mention of 0.4.1 in that paragraph in the wiki.

This seems to be the specific combination required for maximum compatibility with rails 2.3.x:

gem "capybara", "0.3.9"
gem "cucumber", "0.9.4"
gem "cucumber-rails", "0.3.2"

@aslakhellesoy
Cucumber member

Feel free to update the wiki!!

@Vanuan

Did anyone created a cucumber-rails fork that works with Rails 2?

@aslakhellesoy
Cucumber member

Hmm. It would be great if someone could go through each of those, merge in the good parts from each one into one fork/branch. Then I can make a new 0.3.3 release.

@Vanuan

All of those in some way touches capybara_javascript_emulation.rb (renamed to capybara/javascript_emulation.rb) to enable the use of cucumber-rails with the latest capybara.

  1. https://github.com/kidpollo/cucumber-rails/commits/rails_2_x

    Just adds capybara/javascript_emulation.rb from master to v0.3.2. Not very nice.

  2. https://github.com/RKelln/cucumber-rails/commits/0.3.2-capybara-fix

    Backport of #130, and replacing capybara/javascript_emulation.rb from version 1.04

  3. https://github.com/puloms/cucumber-rails/commits/v0.3.2-fix-capybara

    Just backport of #130

  4. https://github.com/umanni/cucumber-rails/commits/v0.3.2-fix

    Not sure what it is. The commit message says: First create the alias to a existing method, then do the reverse.

  5. https://github.com/iceroyale/cucumber-rails/commits/rails2-fix

    Removes requirerails`fromlib/cucumber/rails.rb`. Includes all the changes up to v0.4.1.

  6. https://github.com/infbio/cucumber-rails/commits/disable_javascript_emulation

    Just disables javascript emulation. Includes all the changes up to v0.4.1.

  7. https://github.com/pigletto/cucumber-rails/commits/fixes

    Backport of #130 and 68044f4 combined in one commit.

  8. #200

    Just backport of #130

And, IMHO, my patch #213 contains all the good parts: Based on v0.3.2, backport of #130 and 68044f4 with original authors and bumbing version to v0.3.3. I can revert the bumping version part if you like.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment