Posted 17 days ago. Visible to the public.

Upgrading a Rails app to Cucumber 3

Upgrade gems

You need to update a lof gems. Make sure you don't have any version constraints in your Gemfile or your bundle update won't do anything!

Upgrade cucumber_priority:

bundle update cucumber_priority

Upgrade spreewald:

bundle update spreewald

Upgrade cucumber_factory:

bundle update cucumber_factory

Upgrade parallel_tests:

bundle update parallel_tests

Even on the latest version, parallel_tests will print some deprecation warnings due to using an older formatter API. Maybe there will be a fix for that eventually.

In your Gemfile use cucumber-rails from the current master. It has Cucumber 3 fixes that haven't been relased yet:

gem 'cucumber-rails', require: false, git: ''

Now update cucumber-rails:

bundle update cucumber-rails

Upgrade cucumber:

bundle update cucumber

Make sure you have a recent version of geordi (it doesn't belong in your Gemfile!):

gem install geordi

Check if you're using Transforms

Transform is no longer supported in Cucumber 3.

There is something similiar called ParameterType. A ParameterType is no longer applied blindly to all strings that match. Step definitions need to explicitely define that they're using a ParameterType.

Use the new tag syntax

Cucumber 1/2 Cucumber 3
@tag @tag
~@tag not @tag
@foo, @bar (@foo or @bar)

So you need to replace a hook like this:

AfterStep('~@javascript') do ... end

With this:

AfterStep('not @javascript') do ... end

Also grep your entire project for ~@ and change it to "not @". Note that you need to quote both words if it's a shell command arg.

You will probably find this line in your config/cucumber.yml:

std_opts = "-r features --format #{ENV['CUCUMBER_FORMAT'] || 'progress'} --strict --tags ~@wip"

Change it to:

std_opts = "-r features --format #{ENV['CUCUMBER_FORMAT'] || 'progress'} --strict --tags 'not @wip'"

Fix step definitions

I had some errors like IndexError: index 2 out of matches.

This can have 2 causes:

  • You have a step definition that defines capture groups in its regular expression, but the block takes a different number of arguments.
  • Allegedly the Cucumber 3 parser only counts top-level regexp groups, ignoring nested capture groups (I could not confirm that).

Read more

Upgrading to Cucumber 3.0.0 on

Growing Rails Applications in Practice
Check out our new e-book:
Learn to structure large Ruby on Rails codebases with the tools you already know and love.

Author of this card:

Henning Koch
Last edit:
15 days ago
by Dominik Schöler
About this deck:
We are makandra and do test-driven, agile Ruby on Rails software development.
License for source code
Posted by Henning Koch to makandra dev