Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Rails Generators for Cucumber with special support for Capybara and DatabaseCleaner

License

NotificationsYou must be signed in to change notification settings

cucumber/cucumber-rails

Repository files navigation

Gem VersionbuildOpen Source Helpers

Cucumber-Rails brings Cucumber to Rails 6.1, 7.x, and 8.x.

Installation

Before you can use the generator, add the gem to your project's Gemfile as follows:

group:testdogem'cucumber-rails',require:false# database_cleaner is not required, but highly recommendedgem'database_cleaner'end

Then install it by running:

bundle install

Learn about the various options:

rails generate cucumber:install --help

Finally, bootstrap your Rails app, for example:

rails generate cucumber:install

Running Cucumber

[bundle exec] cucumber

Configuration options

By default, cucumber-rails runsDatabaseCleaner.start andDatabaseCleaner.cleanbefore and after your scenarios. You can disable this behaviour like so:

# features/support/env.rb# ...Cucumber::Rails::Database.autorun_database_cleaner=false

By default, cucumber-rails will auto mix-in the helpers fromRack::Test into your default Cucumber World instance.You can prevent this behaviour like so:

# features/support/env.rbENV['CR_REMOVE_RACK_TEST_HELPERS']='true'

Upgrading from a previous version

When upgrading from a previous version it is recommended that you rerun:

rails generate cucumber:install

Bugs and feature requests

Theonly way to have a bug fixed or a new feature accepted is to describe it with aCucumber feature. Let's say you think you have found a bug in the cucumber:install generator.Fork this project, clone it to your workstation and check out a branch with a descriptive name:

git clone git@github.com:you/cucumber-rails.gitgit checkout -b bugfix/generator-fails-on-bundle-exec

Start by making sure you can run the existing features. Now, create a feature that demonstrateswhat's wrong. See the existing features for examples. When you have a failing feature thatreproduces the bug, commit, push and send a pull request. Someone from the Cucumber-Rails teamwill review it and hopefully create a fix.

If you know how to fix the bug yourself, make a second commit (after committing the failingfeature) before you send the pull request.

Setting up your environment

Make sure you have a supported ruby installed, cd into yourcucumber-rails repository and run

gem install bundlerbundle installbin/install_geckodriver.shbin/install_webpacker.sh

Running all tests

With all dependencies installed, all specs and features should pass:

[bundle exec] rake

Running Appraisal suite

In order to test against multiple versions of key dependencies, theAppraisalgem is used to generate multiple gemfiles, stored in thegemfiles/ directory.Normally these will only run on GitHub via GitHub Actions; however if you want to run the full testsuite against all gemfiles, run the following commands:

[bundle exec] appraisal install[bundle exec] appraisal rake test

To run the suite against a named gemfile, use the following:

[bundle exec] appraisal rails_8_0 rake test

Adding dependencies

To support the multiple-gemfile testing, when adding a new dependency the following rules apply:

  1. If it's a runtime dependency of the gem, add it to the gemspec
  2. If it's a primary development dependency, add it to the gemspec
  3. If it's a dependency of a generated rails app in a test, add it tothe helper method that modifies theGemfile

For example, rspec is a primary development dependency, so it lives in the gemspec.


[8]ページ先頭

©2009-2025 Movatter.jp