Posted 10 months 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:

Copy
bundle update cucumber_priority

Upgrade spreewald:

Copy
bundle update spreewald

Upgrade cucumber_factory:

Copy
bundle update cucumber_factory

Upgrade parallel_tests:

Copy
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.

Update cucumber-rails to >= 1.6.0:

Copy
bundle update cucumber-rails

Upgrade cucumber:

Copy
bundle update cucumber

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

Copy
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:

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

With this:

Copy
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:

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

Change it to:

Copy
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 cucumber.io

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.

Owner of this card:

Avatar
Henning Koch
Last edit:
8 months ago
by Henning Koch
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
This website uses cookies to improve usability and analyze traffic.
Accept or learn more