Skip to content

cucumber/cucumber-ruby

main
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

* For pretty spec remove all multiple expectation cop failures for snippet based tests

* Linting tidy for pretty spec

* Cleanup of file loading tests to ensure that tests only test one thing

* Simplify test for multiple worlds

* Final tweaks to registry and more spec to resolve all specs only having 1 assertion

* Remove all duplicate expectations from meta_message_builder

* Remove nearly all duplicate expect situations from options spec

* Stylistic tweaks to activate steps spec

* Remove double expectation wrappers on essentially allow calls for mocking

* Remove all duplicate expectations from activate_steps spec

* Remove around 30% of multiple expectation offenses

* Partial fix for maximum lets

* Fix up all RSpec/NestedGroups offenses

* Fix up incorrect rubocop fix

* Add in additional note about rubocop fixes
e491902

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
September 1, 2023 15:57
October 3, 2023 09:20
October 3, 2023 09:20
May 25, 2016 23:53
September 11, 2023 18:18
October 3, 2023 09:20

Cucumber Open - Supported by Smartbear

Cucumber

Stand With Ukraine OpenCollective OpenCollective Test cucumber Code Climate Coverage Status

Cucumber is a tool for running automated tests written in plain language. Because they're written in plain language, they can be read by anyone on your team. Because they can be read by anyone, you can use them to help improve communication, collaboration and trust on your team.

Cucumber Gherkin Example

This is the Ruby implementation of Cucumber. Cucumber is also available for JavaScript, Java, and a lot of other languages. You can find a list of implementations here: https://cucumber.io/docs/installation/.

See CONTRIBUTING.md for info on contributing to Cucumber (issues, PRs, etc.).

Everyone interacting in this codebase and issue tracker is expected to follow the Cucumber code of conduct.

Installation

Cucumber for Ruby is a Ruby gem. Install it as you would install any gem: add cucumber to your Gemfile:

gem 'cucumber'

then install it:

$ bundle

or install the gem directly:

$ gem install cucumber

Later in this document, bundler is considered being used so all commands are using bundle exec. If this is not the case for you, execute cucumber directly, without bundle exec.

Supported platforms

  • Ruby 3.2
  • Ruby 3.1
  • Ruby 3.0
  • Ruby 2.7
  • TruffleRuby 22.0.0+
  • JRuby 9.4+ (with some limitations)

Ruby on Rails

Using Ruby on Rails? You can use cucumber-rails to bring Cucumber into your Rails project.

Usage

Initialization

If you need to, initialize your features directory with

$ bundle exec cucumber --init

This will create the following directories and files if they do not exist already:

features
├── step_definitions
└── support
    └── env.rb

Create your specification

Create a file named rule.feature in the features directory with:

# features/rule.feature

Feature: Rule Sample

  Rule: This is a rule

    Example: A passing example
      Given this will pass
      When I do an action
      Then some results should be there

    Example: A failing example
      Given this will fail
      When I do an action
      Then some results should be there

Automate your specification

And a file named steps.rb in features/step_definitions with:

# features/step_definitions/steps.rb

Given('this will pass') do
  @this_will_pass = true
end

Given('this will fail') do
  @this_will_pass = false
end

When('I do an action') do
  :no_op
end

Then("some results should be there") do
  expect(@this_will_pass).to be true
end

Run Cucumber

$ bundle exec cucumber

To execute a single feature file:

$ bundle exec cucumber features/rule.feature

To execute a single example, indicates the line of the name of the example:

$ bundle exec cucumber features/rule.feature:5

To summarize the results on the standard output, and generate a HTML report on disk:

$ bundle exec cucumber --format summary --format html --out report.html

For more command line options

$ bundle exec cucumber --help

You can also find documentation on the command line possibilities in features/docs/cli.

Documentation and support

Copyright (c) Cucumber Ltd. and Contributors. See LICENSE for details.