You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

README.md 5.7 kB

2 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. <p align="center">
  2. <img src="./.github/img/cucumber-open-logo.png" alt="Cucumber Open - Supported by Smartbear" width="428" />
  3. </p>
  4. # Cucumber
  5. [![Stand With Ukraine](https://raw.githubusercontent.com/vshymanskyy/StandWithUkraine/main/badges/StandWithUkraine.svg)](https://vshymanskyy.github.io/StandWithUkraine)
  6. [![OpenCollective](https://opencollective.com/cucumber/backers/badge.svg)](https://opencollective.com/cucumber)
  7. [![OpenCollective](https://opencollective.com/cucumber/sponsors/badge.svg)](https://opencollective.com/cucumber)
  8. [![pull requests](https://oselvar.com/api/badge?label=pull%20requests&csvUrl=https%3A%2F%2Fraw.githubusercontent.com%2Fcucumber%2Foselvar-github-metrics%2Fmain%2Fdata%2Fcucumber%2Fcucumber-ruby%2FpullRequests.csv)](https://oselvar.com/github/cucumber/oselvar-github-metrics/main/cucumber/cucumber-ruby)
  9. [![issues](https://oselvar.com/api/badge?label=issues&csvUrl=https%3A%2F%2Fraw.githubusercontent.com%2Fcucumber%2Foselvar-github-metrics%2Fmain%2Fdata%2Fcucumber%2Fcucumber-ruby%2Fissues.csv)](https://oselvar.com/github/cucumber/oselvar-github-metrics/main/cucumber/cucumber-ruby)
  10. [![Test cucumber](https://github.com/cucumber/cucumber-ruby/actions/workflows/cucumber-ruby.yml/badge.svg)](https://github.com/cucumber/cucumber-ruby/actions/workflows/cucumber-ruby.yml)
  11. [![Code Climate](https://codeclimate.com/github/cucumber/cucumber-ruby.svg)](https://codeclimate.com/github/cucumber/cucumber-ruby)
  12. [![Coverage Status](https://coveralls.io/repos/cucumber/cucumber-ruby/badge.svg?branch=main)](https://coveralls.io/r/cucumber/cucumber-ruby?branch=main)
  13. Cucumber is a tool for running automated tests written in plain language. Because they're
  14. written in plain language, they can be read by anyone on your team. Because they can be
  15. read by anyone, you can use them to help improve communication, collaboration and trust on
  16. your team.
  17. <p align="center">
  18. <img src="./.github/img/gherkin-example.png" alt="Cucumber Gherkin Example" width="728" />
  19. </p>
  20. This is the Ruby implementation of Cucumber. Cucumber is also available for [JavaScript](https://github.com/cucumber/cucumber-js),
  21. [Java](https://github.com/cucumber/cucumber-jvm), and a lot of other languages. You can find a list of implementations here: https://cucumber.io/docs/installation/.
  22. See [CONTRIBUTING.md](CONTRIBUTING.md) for info on contributing to Cucumber (issues, PRs, etc.).
  23. Everyone interacting in this codebase and issue tracker is expected to follow the
  24. Cucumber [code of conduct](https://cucumber.io/conduct).
  25. ## Installation
  26. Cucumber for Ruby is a Ruby gem. Install it as you would install any gem: add
  27. `cucumber` to your Gemfile:
  28. gem 'cucumber'
  29. then install it:
  30. $ bundle
  31. or install the gem directly:
  32. $ gem install cucumber
  33. Later in this document, bundler is considered being used so all commands are using
  34. `bundle exec`. If this is not the case for you, execute `cucumber` directly, without
  35. `bundle exec`.
  36. ### Supported platforms
  37. - Ruby 3.2
  38. - Ruby 3.1
  39. - Ruby 3.0
  40. - Ruby 2.7
  41. - Ruby 2.6
  42. - TruffleRuby 22.0.0+
  43. - JRuby (with [some limitations](https://github.com/cucumber/cucumber-ruby/blob/main/docs/jruby-limitations.md))
  44. - 9.3 >= 9.3.1 (there is a known issue with JRuby 9.3.0. More info can
  45. be found in the [PR#1571](https://github.com/cucumber/cucumber-ruby/pull/1571).)
  46. ### Ruby on Rails
  47. Using Ruby on Rails? You can use [cucumber-rails](https://github.com/cucumber/cucumber-rails)
  48. to bring Cucumber into your Rails project.
  49. ## Usage
  50. ### Initialization
  51. If you need to, initialize your `features` directory with
  52. $ bundle exec cucumber --init
  53. This will create the following directories and files if they do not exist already:
  54. features
  55. ├── step_definitions
  56. └── support
  57. └── env.rb
  58. ### Create your specification
  59. Create a file named `rule.feature` in the `features` directory with:
  60. ```gherkin
  61. # features/rule.feature
  62. Feature: Rule Sample
  63. Rule: This is a rule
  64. Example: A passing example
  65. Given this will pass
  66. When I do an action
  67. Then some results should be there
  68. Example: A failing example
  69. Given this will fail
  70. When I do an action
  71. Then some results should be there
  72. ```
  73. ### Automate your specification
  74. And a file named `steps.rb` in `features/step_definitions` with:
  75. ```ruby
  76. # features/step_definitions/steps.rb
  77. Given("this will pass") do
  78. @this_will_pass = true
  79. end
  80. Given("this will fail") do
  81. @this_will_pass = false
  82. end
  83. When("I do an action") do
  84. end
  85. Then("some results should be there") do
  86. expect(@this_will_pass)
  87. end
  88. ```
  89. ### Run Cucumber
  90. $ bundle exec cucumber
  91. To execute a single feature file:
  92. $ bundle exec cucumber features/rule.feature
  93. To execute a single example, indicates the line of the name of the example:
  94. $ bundle exec cucumber features/rule.feature:7
  95. To summarize the results on the standard output, and writte a HTML report on disk:
  96. $ bundle exec cucumber --format summary --format html --out report.html
  97. For more command line options
  98. $ bundle exec cucumber --help
  99. You can also find documentation on the command line possibilities in
  100. [features/docs/cli](features/docs/cli).
  101. ## Documentation and support
  102. - Getting started, writing features, step definitions, and more: https://cucumber.io/docs
  103. - Ruby API Documentation: http://www.rubydoc.info/github/cucumber/cucumber-ruby/
  104. - Community support forum: https://community.smartbear.com/t5/Cucumber-Open/bd-p/CucumberOS
  105. - Slack: [register for an account](https://cucumberbdd-slack-invite.herokuapp.com/) then head over to [#intro](https://cucumberbdd.slack.com/messages/C5WD8SA21/)
  106. ## Copyright
  107. Copyright (c) Cucumber Ltd. and Contributors. See LICENSE for details.

No Description

Contributors (1)