Skip to content
Overridable step definitions for Cucumber
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
bin
lib
spec
.gitignore
.rspec
.ruby-version
.travis.yml
Gemfile
Gemfile.cucumber-1.3
Gemfile.cucumber-1.3.lock
Gemfile.cucumber-2.4
Gemfile.cucumber-2.4.lock
Gemfile.cucumber-3.0
Gemfile.cucumber-3.0.lock
Gemfile.cucumber-3.1
Gemfile.cucumber-3.1.lock
Gemfile.lock
LICENSE
README.md
Rakefile
cucumber_priority.gemspec

README.md

cucumber_priority Build Status

Overridable step definitions for Cucumber

Cucumber raises an error if more than one step definitions match a step.

This gem provides a way to mark step definitions as overridable, meaning that they can always be overshadowed by a more specific version without raising an error.

Examples

Marking step definitions as overridable

To mark a step definition as overridable, call #overridable on the definition object:

Given /^there is a movie with a (.*?) tone$/ do
  ...
end.overridable

Given /^there is a movie with a funny tone$/ do
  ...
end

The following step will now no longer raise Cucumber::Ambiguous:

Given there is a movie with a funny tone

If a step matches more than one non-overridable steps, Cucumber will still raise Cucumber::Ambiguous.

Defining priorities

You can define priorities for overridable steps by passing an numeric :priority option to #overridable:

Given /^there is a movie with a (.*?) tone$/ do
  ...
end.overridable(priority: 1)

Given /^there is a movie with a (sad|upbeat|disturbing) tone$/ do
  ...
end.overridable(priority: 5)

A higher priority wins the match.

A non-overridable step will always win over an overridable step regardless of its priority.

Supported Cucumber versions

cucumber_priority is tested against Cucumber 1.3, 2.4, 3.0 and 3.1.

Installation

In your Gemfile say:

gem 'cucumber_priority'

Now run bundle install and restart your server.

Development

There are tests in spec. We only accept PRs with tests. To run tests:

  • Install Ruby 2.5.0
  • Install development dependencies using bundle install
  • Run tests using bundle exec rspec

We recommend to test large changes against multiple versions of Ruby and multiple dependency sets. Supported combinations are configured in .travis.yml. We provide some rake tasks to help with this:

  • Install development dependencies using bundle matrix:install
  • Run tests using bundle matrix:spec

Note that we have configured Travis CI to automatically run tests in all supported Ruby versions and dependency sets after each push. We will only merge pull requests after a green Travis build.

If you would like to contribute:

  • Fork the repository.
  • Push your changes with passing specs.
  • Send us a pull request.

I'm very eager to keep this gem leightweight and on topic. If you're unsure whether a change would make it into the gem talk to me beforehand.

Credits

Henning Koch from makandra

You can’t perform that action at this time.