Cucumber School Logo

Watch the Cucumber School video lesson on installing Cucumber for Ruby here.

Cucumber for Ruby is a Ruby gem. Depending on your project structure there are several ways to install it:


Install from the command line:

gem install cucumber

Bundler (without Rails)

Add cucumber to your Gemfile:

gem 'cucumber'

Install the gem:


Try it out:

cucumber --help

Then, initialize a features/ directory:

cucumber --init

Bundler is a utility gem that manages project specific RubyGem dependencies such that each Rails project is unaffected by the gem requirements of another. If you use Bundler to support multiple gem versions in multiple Rails projects on a single development host then you must run Cucumber using the preface bundle exec. For example: bundle exec cucumber -pnone features.

Ruby on Rails

Cucumber-Rails is a gem that Rails projects can use to install cucumber and create its configuration.

Add cucumber-rails to your Gemfile: (Note: you do not need to add Cucumber)

group :test do
  gem 'cucumber-rails', require: false
  # database_cleaner is not mandatory, but highly recommended
  gem 'database_cleaner'

Install the gem:


Learn about the various options:

rails generate cucumber:install --help

Run the generator:

rails generate cucumber:install

Cucumber-Rails will detect whether the RSpec gems are installed. If so, then the rails generator builds the environment files to suit. If not, it ignores RSpec and configures for test-unit instead.

You can help us improve this documentation. Edit this page.