cucumber 3.1.2 → 8.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (125) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +1880 -1146
  3. data/CONTRIBUTING.md +220 -61
  4. data/README.md +143 -22
  5. data/bin/cucumber +1 -1
  6. data/lib/autotest/cucumber_mixin.rb +49 -53
  7. data/lib/autotest/discover.rb +3 -2
  8. data/lib/cucumber/cli/configuration.rb +32 -7
  9. data/lib/cucumber/cli/main.rb +16 -15
  10. data/lib/cucumber/cli/options.rb +111 -79
  11. data/lib/cucumber/cli/profile_loader.rb +45 -26
  12. data/lib/cucumber/cli/rerun_file.rb +1 -1
  13. data/lib/cucumber/configuration.rb +47 -31
  14. data/lib/cucumber/constantize.rb +3 -6
  15. data/lib/cucumber/deprecate.rb +32 -7
  16. data/lib/cucumber/errors.rb +5 -7
  17. data/lib/cucumber/events/envelope.rb +9 -0
  18. data/lib/cucumber/events/gherkin_source_parsed.rb +11 -0
  19. data/lib/cucumber/events/hook_test_step_created.rb +12 -0
  20. data/lib/cucumber/events/step_activated.rb +0 -5
  21. data/lib/cucumber/events/step_definition_registered.rb +0 -5
  22. data/lib/cucumber/events/test_case_created.rb +12 -0
  23. data/lib/cucumber/events/test_case_ready.rb +12 -0
  24. data/lib/cucumber/events/test_run_finished.rb +2 -1
  25. data/lib/cucumber/events/test_step_created.rb +12 -0
  26. data/lib/cucumber/events/undefined_parameter_type.rb +9 -0
  27. data/lib/cucumber/events.rb +15 -8
  28. data/lib/cucumber/file_specs.rb +8 -7
  29. data/lib/cucumber/filters/activate_steps.rb +6 -3
  30. data/lib/cucumber/filters/broadcast_test_case_ready_event.rb +12 -0
  31. data/lib/cucumber/filters/prepare_world.rb +5 -9
  32. data/lib/cucumber/filters/quit.rb +1 -3
  33. data/lib/cucumber/filters/tag_limits/verifier.rb +3 -7
  34. data/lib/cucumber/filters/tag_limits.rb +1 -3
  35. data/lib/cucumber/filters.rb +1 -0
  36. data/lib/cucumber/formatter/ansicolor.rb +74 -86
  37. data/lib/cucumber/formatter/ast_lookup.rb +163 -0
  38. data/lib/cucumber/formatter/backtrace_filter.rb +10 -7
  39. data/lib/cucumber/formatter/console.rb +76 -68
  40. data/lib/cucumber/formatter/console_counts.rb +4 -9
  41. data/lib/cucumber/formatter/console_issues.rb +12 -4
  42. data/lib/cucumber/formatter/duration.rb +1 -1
  43. data/lib/cucumber/formatter/duration_extractor.rb +4 -1
  44. data/lib/cucumber/formatter/errors.rb +7 -0
  45. data/lib/cucumber/formatter/fanout.rb +3 -1
  46. data/lib/cucumber/formatter/html.rb +11 -598
  47. data/lib/cucumber/formatter/http_io.rb +152 -0
  48. data/lib/cucumber/formatter/ignore_missing_messages.rb +2 -2
  49. data/lib/cucumber/formatter/interceptor.rb +11 -30
  50. data/lib/cucumber/formatter/io.rb +57 -13
  51. data/lib/cucumber/formatter/json.rb +119 -124
  52. data/lib/cucumber/formatter/junit.rb +75 -55
  53. data/lib/cucumber/formatter/message.rb +23 -0
  54. data/lib/cucumber/formatter/message_builder.rb +256 -0
  55. data/lib/cucumber/formatter/pretty.rb +370 -153
  56. data/lib/cucumber/formatter/progress.rb +31 -32
  57. data/lib/cucumber/formatter/publish_banner_printer.rb +77 -0
  58. data/lib/cucumber/formatter/query/hook_by_test_step.rb +32 -0
  59. data/lib/cucumber/formatter/query/pickle_by_test.rb +26 -0
  60. data/lib/cucumber/formatter/query/pickle_step_by_test_step.rb +26 -0
  61. data/lib/cucumber/formatter/query/step_definitions_by_test_step.rb +40 -0
  62. data/lib/cucumber/formatter/query/test_case_started_by_test_case.rb +42 -0
  63. data/lib/cucumber/formatter/rerun.rb +24 -4
  64. data/lib/cucumber/formatter/stepdefs.rb +1 -2
  65. data/lib/cucumber/formatter/steps.rb +8 -6
  66. data/lib/cucumber/formatter/summary.rb +17 -8
  67. data/lib/cucumber/formatter/unicode.rb +18 -20
  68. data/lib/cucumber/formatter/url_reporter.rb +17 -0
  69. data/lib/cucumber/formatter/usage.rb +18 -15
  70. data/lib/cucumber/gherkin/data_table_parser.rb +18 -6
  71. data/lib/cucumber/gherkin/formatter/ansi_escapes.rb +14 -18
  72. data/lib/cucumber/gherkin/formatter/escaping.rb +2 -2
  73. data/lib/cucumber/gherkin/steps_parser.rb +17 -8
  74. data/lib/cucumber/glue/dsl.rb +29 -15
  75. data/lib/cucumber/glue/hook.rb +37 -11
  76. data/lib/cucumber/glue/invoke_in_world.rb +17 -22
  77. data/lib/cucumber/glue/proto_world.rb +47 -53
  78. data/lib/cucumber/glue/registry_and_more.rb +62 -17
  79. data/lib/cucumber/glue/registry_wrapper.rb +31 -0
  80. data/lib/cucumber/glue/snippet.rb +23 -22
  81. data/lib/cucumber/glue/step_definition.rb +48 -23
  82. data/lib/cucumber/glue/world_factory.rb +1 -1
  83. data/lib/cucumber/hooks.rb +12 -11
  84. data/lib/cucumber/multiline_argument/data_table/diff_matrices.rb +4 -3
  85. data/lib/cucumber/multiline_argument/data_table.rb +143 -123
  86. data/lib/cucumber/multiline_argument/doc_string.rb +1 -1
  87. data/lib/cucumber/multiline_argument.rb +4 -6
  88. data/lib/cucumber/platform.rb +5 -5
  89. data/lib/cucumber/rake/task.rb +34 -25
  90. data/lib/cucumber/rspec/disable_option_parser.rb +15 -11
  91. data/lib/cucumber/rspec/doubles.rb +3 -5
  92. data/lib/cucumber/running_test_case.rb +3 -53
  93. data/lib/cucumber/runtime/after_hooks.rb +8 -4
  94. data/lib/cucumber/runtime/before_hooks.rb +8 -4
  95. data/lib/cucumber/runtime/for_programming_languages.rb +4 -2
  96. data/lib/cucumber/runtime/meta_message_builder.rb +106 -0
  97. data/lib/cucumber/runtime/step_hooks.rb +6 -2
  98. data/lib/cucumber/runtime/support_code.rb +16 -15
  99. data/lib/cucumber/runtime/user_interface.rb +10 -19
  100. data/lib/cucumber/runtime.rb +78 -76
  101. data/lib/cucumber/step_definition_light.rb +4 -3
  102. data/lib/cucumber/step_definitions.rb +2 -2
  103. data/lib/cucumber/step_match.rb +17 -20
  104. data/lib/cucumber/step_match_search.rb +5 -3
  105. data/lib/cucumber/term/ansicolor.rb +72 -48
  106. data/lib/cucumber/term/banner.rb +57 -0
  107. data/lib/cucumber/version +1 -1
  108. data/lib/cucumber.rb +3 -2
  109. data/lib/simplecov_setup.rb +1 -1
  110. metadata +279 -81
  111. data/lib/cucumber/core_ext/string.rb +0 -11
  112. data/lib/cucumber/events/gherkin_source_parsed.rb~ +0 -14
  113. data/lib/cucumber/formatter/ast_lookup.rb~ +0 -9
  114. data/lib/cucumber/formatter/cucumber.css +0 -286
  115. data/lib/cucumber/formatter/cucumber.sass +0 -247
  116. data/lib/cucumber/formatter/hook_query_visitor.rb +0 -42
  117. data/lib/cucumber/formatter/html_builder.rb +0 -121
  118. data/lib/cucumber/formatter/inline-js.js +0 -30
  119. data/lib/cucumber/formatter/jquery-min.js +0 -154
  120. data/lib/cucumber/formatter/json_pretty.rb +0 -11
  121. data/lib/cucumber/formatter/legacy_api/adapter.rb +0 -1028
  122. data/lib/cucumber/formatter/legacy_api/ast.rb +0 -394
  123. data/lib/cucumber/formatter/legacy_api/results.rb +0 -50
  124. data/lib/cucumber/formatter/legacy_api/runtime_facade.rb +0 -32
  125. data/lib/cucumber/step_argument.rb +0 -25
data/CONTRIBUTING.md CHANGED
@@ -1,87 +1,246 @@
1
- ## About to create a new Github Issue?
1
+ # Contributing to Cucumber
2
2
 
3
- We appreciate that. But before you do, please learn our basic rules:
3
+ Thank you for considering contributing to Cucumber!
4
4
 
5
- * This is not a support forum. If you have a question, please go to [The Cukes Google Group](http://groups.google.com/group/cukes).
6
- * Do you have an idea for a new feature? Then don't expect it to be implemented unless you or someone else sends a [pull request](https://help.github.com/articles/using-pull-requests). You might be better to start a discussion on [the google group](http://groups.google.com/group/cukes).
7
- * Reporting a bug? Please tell us:
8
- * which version of Cucumber you're using
9
- * which version of Ruby you're using.
10
- * How to reproduce it. Bugs with a failing test in a [pull request](https://help.github.com/articles/using-pull-requests) get fixed much quicker. Some bugs may never be fixed.
11
- * Want to paste some code or output? Put \`\`\` on a line above and below your code/output. See [GFM](https://help.github.com/articles/github-flavored-markdown)'s *Fenced Code Blocks* for details.
12
- * We love [pull requests](https://help.github.com/articles/using-pull-requests). But if you don't have a test to go with it we probably won't merge it.
5
+ This document will first introduce different ways to get involved before
6
+ focusing on how to contribute to the code.
13
7
 
14
- # Contributing to Cucumber
8
+ ## Code of Conduct
9
+
10
+ Everyone interacting in this codebase and issue tracker is expected to follow
11
+ the Cucumber [code of conduct](https://cucumber.io/conduct).
12
+
13
+ ## How can I contribute?
14
+
15
+ If you're reading this, you are certainly looking to contribute to the code. Cucumber
16
+ is not this single repository. It is made up of several packages around several
17
+ repositories. So before going further with the code, you may consider the
18
+ following first, in order to get your bearings.
19
+
20
+ If you just want to know how to contribute to the code, go to
21
+ [Contribute to the code](#contribute-to-the-code).
22
+
23
+ If you want to report an issue, or suggest an enhancement, go to
24
+ [Report bugs and submit feature requests](#report-bugs-and-submit-feature-requests).
25
+
26
+ ### Meet the community, the maintainers, and other Cucumber developers
27
+
28
+ Smartbear hosts a [community message board].
29
+ This is a good place to meet users, the community, and to ask questions.
30
+
31
+ You can also join the Cucumber Community Slack:
32
+ [register for an account][register-slack] then head over to [#intro][slack-intro].
33
+ This is the place to be to meet other contributors and find a mentor to help you
34
+ get started.
35
+
36
+ ### Test Cucumber
37
+
38
+ Testing Cucumber, especially new features, is a great way to contribute. We
39
+ cannot put a price on (early) feedback.
40
+
41
+ Keep an eye on our CHANGELOGS to discover new features. Test and experiment, and
42
+ submit your feedback through [issues](#report-bugs-and-submit-feature-requests),
43
+ the [community message board], or [Slack][community-slack].
44
+
45
+ ### Contribute to the documentation
46
+
47
+ [The documentation][cucumber-docs] is an important part of Cucumber. It is
48
+ essential that it remains simple and accurate. You can contribute to it via
49
+ [github.com/cucumber/docs](https://github.com/cucumber/docs).
50
+
51
+ ### Promote Cucumber
52
+
53
+ You don't know how to contribute but would like to help? Telling other people
54
+ about Cucumber on the Internet - social media, reviews, blogs - but also in real
55
+ life is already a big help! Join us on [Slack][community-slack] to share your
56
+ publication and to discover new ones.
57
+
58
+ ## Report bugs and submit feature requests
59
+
60
+ The short version is:
61
+
62
+ - Find the appropriate repository
63
+ - Try to check there is not already an issue or pull request that deals with
64
+ your bug or request
65
+ - Explain your issue and include as much details as possible to help other
66
+ people reproduce your problem or understand your request
67
+ - Consider submitting a pull request if you feel confident enough
68
+
69
+ You can find more details for each of these steps in the following sections.
70
+
71
+ ### Find the appropriate repository
72
+
73
+ The current repository, `cucumber-ruby`, is actually the tip of the iceberg. It
74
+ provides a user interface through a CLI, some built-in formatters, and the
75
+ execution environment you may know as the `World` object.
76
+
77
+ An important repository is [cucumber/common]. It is a mono-repo
78
+ with a lot of libraries. You will find there what is related to:
79
+
80
+ - parsing Gherkin documents - aka `.feature` files
81
+ - parsing tag expressions - the options you use to filter an execution with tags
82
+ - parsing Cucumber expressions - the expressions that link a Gherkin step to a
83
+ step definition
84
+ - everyting related to the HTML formatter
85
+
86
+ `cucumber-ruby` is also composed of [cucumber-ruby-core]: this is the engine that
87
+ will execute the test cases computed from a parsed Gherkin document
88
+
89
+ Last but not least, there is also a repository for [cucumber-rails], the gem
90
+ that brings Cucumber to Rails 5.x and 6.x.
91
+
92
+ In any case, if your are not sure, best places to open an issue are the current
93
+ repository - `cucumber-ruby` - and the mono-repo at [cucumber/common].
94
+
95
+ ### Look for existing issues and pull requests
96
+
97
+ Search in [the current repository][cucumber-ruby-issues], in the
98
+ [mono-repo][cucumber/common-issues], but also in the
99
+ [whole cucumber organization][cucumber-issues] if the problem or feature has already
100
+ been reported. If you find an issue or pull request which is still open, add
101
+ comments to it instead of opening a new one.
102
+
103
+ If you're not sure, don't hesitate to just open a new issue. We can always merge
104
+ and de-duplicate later.
105
+
106
+ ### Submitting a pull request
107
+
108
+ When submitting a pull request:
109
+
110
+ - create a [draft pull request][how-to-create-a-draft-pr]
111
+ - try to follow the instructions in the [template](.github/PULL_REQUEST_TEMPLATE.md)
112
+ - if possible, [sign your commits]
113
+ - update CHANGELOG.md with your changes
114
+ - once the PR is ready, request for reviews
115
+
116
+ More info on [how to contribute to the code](#contribute-to-the-code) can be
117
+ found below.
118
+
119
+ ### Opening a new issue
120
+
121
+ To open a good issue, be clear and precise.
122
+
123
+ If you report a problem, the reader must be able to reproduce it easily.
124
+ Please do your best to create a [minimal, reproducible example][minimal-reproducible-example].
125
+
126
+ Consider submitting a pull request. Even if you think you cannot fix it by
127
+ yourself, a pull request with a failing test is always welcome.
128
+
129
+ If you request is for an enhancement - a new feature - try to be specific and
130
+ support your request with referenced facts and include examples to illustrate
131
+ your proposal.
132
+
133
+ ## Contribute to the code
134
+
135
+ ### Development environment
136
+
137
+ Development environment for `cucumber-ruby` is a simple Ruby environment with
138
+ Bundler. Use a [supported Ruby version](./README.md#supported-platforms), make
139
+ sure [Bundler] is set-up, and voilà!
140
+
141
+ You can then [fork][how-to-fork] and clone the repository. If your environment
142
+ is set-up properly, the following commands should install the dependencies and
143
+ execute all the tests successfully.
144
+
145
+ ```shell
146
+ bundle install
147
+ bundle exec rake
148
+ ```
149
+
150
+ You can now create a branch for your changes and [submit a pull request](#submitting-a-pull-request)!
151
+
152
+ If you want to check the code coverage during your development, execute
153
+ `bundle exec rake cov`.
154
+
155
+ ### Cucumber-ruby-core
15
156
 
16
- The rest of this document is a guide for those maintaining Cucumber, and others who would like to submit patches.
157
+ As seen here: [Find the appropriate repository](#find-the-appropriate-repository),
158
+ you may need to work with other repositories in order to accomplish your
159
+ development. Beside the mono-repo in [cucumber/common], [cucumber-ruby-core] is
160
+ also a big piece of `cucumber-ruby`.
17
161
 
18
- ## Talking with other devs
162
+ ### Using a local Gemfile
19
163
 
20
- You can chat with the core team on https://gitter.im/cucumber/contributors. We try to have office hours on Fridays.
164
+ A local Gemfile allows you to use your prefer set of gems for your own
165
+ development workflow, like gems dedicated to debugging. Such gems are not part
166
+ of `cucumber-ruby` standard `Gemfile`.
21
167
 
22
- ## Installing your own gems
168
+ `Gemfile.local`, `Gemfile.local.lock` and `.bundle` have been added to
169
+ `.gitignore` so local changes cannot be accidentaly commited and pushed to the
170
+ repository.
23
171
 
24
- A `Gemfile.local`-file can be used to have your own gems installed to support
25
- your normal development workflow.
172
+ A `Gemfile.local` may look like this:
26
173
 
27
- Example:
174
+ ```ruby
175
+ # Gemfile.local
28
176
 
29
- ~~~ruby
30
- gem 'pry'
31
- gem 'pry-byebug'
32
- gem 'byebug'
33
- ~~~
177
+ # Include the regular Gemfile
178
+ eval File.read('Gemfile')
34
179
 
35
- ## Note on Patches/Pull Requests
180
+ # Include your favorites development gems
181
+ group :development do
182
+ gem 'byebug'
183
+ gem 'pry'
184
+ gem 'pry-byebug'
36
185
 
37
- * Fork the project. Make a branch for your change.
38
- * Make your feature addition or bug fix.
39
- * Make sure your patch is well covered by tests. We don't accept changes to Cucumber that aren't tested.
40
- * Please do not change the Rakefile, version, or history.
41
- (if you want to have your own version, that is fine but
42
- bump version in a commit by itself so we can ignore when we merge your change)
43
- * Send us a pull request.
186
+ gem 'debase', require: false
187
+ gem 'ruby-debug-ide', require: false
188
+ end
189
+ ```
44
190
 
45
- ## Running tests
191
+ Then you can execute bundler with the `--gemfile` flag:
192
+ `bundle install --gemfile Gemfile.local`, or with an environment variable:
193
+ `BUNDLE_GEMFILE=Gemfile.local bundle [COMMAND]`.
46
194
 
47
- gem install bundler
48
- bundle install
49
- bundle exec rake
195
+ To use your local Gemfile per default, you can also execute
196
+ `bundle config set --local gemfile Gemfile.local`.
50
197
 
51
- To get code coverage results, run `bundle exec rake cov`
198
+ ### First timer? Welcome!
52
199
 
53
- ## First timer? No problem!
200
+ Looking for something simple to begin with? Look at issues with the label
201
+ '[good first issue](https://github.com/cucumber/cucumber-ruby/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22)'.
54
202
 
55
- If you are new to the project or to OSS, check the label
56
- [Easy](https://github.com/cucumber/cucumber-ruby/labels/Easy). Also, you can
57
- help us to correct style violations reported here:
58
- [.rubocop_todo.yaml](https://github.com/cucumber/cucumber-ruby/blob/master/.rubocop_todo.yml).
203
+ Remember: Cucumber is more than `cucumber-ruby`. You can look for good first
204
+ issues in [other cucumber reporistories](#find-the-appropriate-repository).
59
205
 
60
- ## Release Process
206
+ ### Having trouble getting started with the code? We're here to help!
61
207
 
62
- * Bump the version number in `lib/cucumber/version`.
63
- * Make sure `CHANGELOG.md` is updated with the upcoming version number, and has entries for all fixes.
208
+ If you have trouble setting-up your development environment, or getting started
209
+ with the code, you can join us on [Slack][community-slack]. You will find there
210
+ a lot of contributors.
64
211
 
65
- Now release it
212
+ Full-time maintainers are also available. We would be please to have 1:1 pairing
213
+ sessions to help you getting started. Look for
214
+ [Matt Wynne](https://cucumberbdd.slack.com/team/U590XDLF3) or
215
+ [Aurélien Reeves](https://cucumberbdd.slack.com/team/U011BB95MC7) on
216
+ [Slack][community-slack].
66
217
 
67
- bundle update
68
- bundle exec rake
69
- git commit -m "Release X.Y.Z"
70
- rake release
218
+ ### Additional documentation and notice
71
219
 
72
- ## Gaining Release Karma
220
+ You can find additional documentation in the [docs](./docs) directory such as
221
+ (non-exhaustive list):
73
222
 
74
- To become a release manager, create a pull request adding your name to the list below, and include your Rubygems email address in the ticket. One of the existing Release managers will then add you.
223
+ - [How to release cucumber-ruby](./docs/RELEASE_PROCESS.md) (for maintainers)
224
+ - [How to set-up a launch.json configuration for Visual Studio Code](./docs/vscode-example-launch-configuration.md)
75
225
 
76
- Current release managers:
77
- * [Matt Wynne](https://rubygems.org/profiles/mattwynne)
78
- * [Aslak Hellesøy](https://rubygems.org/profiles/aslakhellesoy)
79
- * [Oleg Sukhodolsky](https://rubygems.org/profiles/os97673)
80
- * [Steve Tooke](https://rubygems.org/profiles/tooky)
81
- * [Björn Rasmusson](https://rubygems.org/profiles/brasmusson)
82
- * [Andrew Walter](https://rubygems.org/profiles/xtrasimplicity)
83
226
 
84
- To grant release karma, issue the following commands:
227
+ <!-- Links -->
85
228
 
86
- gem owner cucumber --add <NEW OWNER RUBYGEMS EMAIL>
87
- gem owner cucumber-core --add <NEW OWNER RUBYGEMS EMAIL>
229
+ [community message board]: https://community.smartbear.com/t5/Cucumber-Open/bd-p/CucumberOS
230
+ [register-slack]: https://cucumberbdd-slack-invite.herokuapp.com/
231
+ [slack-intro]: https://cucumberbdd.slack.com/messages/C5WD8SA21/
232
+ [community-slack]: https://cucumberbdd.slack.com/
233
+ [cucumber-docs]: https://cucumber.io/docs/cucumber
234
+ [cucumber/common]: https://github.com/cucumber/common
235
+ [cucumber-ruby-core]: https://github.com/cucumber/cucumber-ruby-core
236
+ [cucumber-rails]: https://github.com/cucumber/cucumber-rails
237
+ [cucumber-ruby-issues]: https://github.com/cucumber/cucumber-ruby/search?q=is%3Aissue
238
+ [cucumber/common-issues]: https://github.com/cucumber/common/search?q=is%3Aissue
239
+ [cucumber-issues]: https://github.com/search?q=is%3Aissue+user%3Acucumber
240
+ [how-to-create-a-draft-pr]: https://docs.github.com/github/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-pull-requests#draft-pull-requests
241
+ [how-to-fork]: https://docs.github.com/github/collaborating-with-pull-requests/working-with-forks/about-forks
242
+ [sign your commits]: https://docs.github.com/en/github/authenticating-to-github/managing-commit-signature-verification/signing-commits
243
+ [minimal-reproducible-example]: https://stackoverflow.com/help/minimal-reproducible-example
244
+ [RVM]: https://rvm.io/
245
+ [rbenv]: https://github.com/rbenv/rbenv
246
+ [Bundler]: https://bundler.io/
data/README.md CHANGED
@@ -1,39 +1,160 @@
1
- [![OpenCollective](https://opencollective.com/cucumber/backers/badge.svg)](https://opencollective.com/cucumber)
2
- [![OpenCollective](https://opencollective.com/cucumber/sponsors/badge.svg)](https://opencollective.com/cucumber)
1
+ <p align="center">
2
+ <img src="./.github/img/cucumber-open-logo.png" alt="Cucumber Open - Supported by Smartbear" width="428" />
3
+ </p>
3
4
 
4
- [![CircleCI](https://circleci.com/gh/cucumber/cucumber-ruby.svg?style=svg)](https://circleci.com/gh/cucumber/cucumber-ruby)
5
+ # Cucumber
5
6
 
7
+ [![Stand With Ukraine](https://raw.githubusercontent.com/vshymanskyy/StandWithUkraine/main/badges/StandWithUkraine.svg)](https://vshymanskyy.github.io/StandWithUkraine)
8
+ [![OpenCollective](https://opencollective.com/cucumber/backers/badge.svg)](https://opencollective.com/cucumber)
9
+ [![OpenCollective](https://opencollective.com/cucumber/sponsors/badge.svg)](https://opencollective.com/cucumber)
10
+ [![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)
11
+ [![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)
12
+ [![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)
6
13
  [![Code Climate](https://codeclimate.com/github/cucumber/cucumber-ruby.svg)](https://codeclimate.com/github/cucumber/cucumber-ruby)
7
- [![Coverage Status](https://coveralls.io/repos/cucumber/cucumber-ruby/badge.svg?branch=master)](https://coveralls.io/r/cucumber/cucumber-ruby?branch=master)
8
- [![Dependency Status](https://gemnasium.com/cucumber/cucumber-ruby.svg)](https://gemnasium.com/cucumber/cucumber-ruby)
9
-
10
- # Cucumber
14
+ [![Coverage Status](https://coveralls.io/repos/cucumber/cucumber-ruby/badge.svg?branch=main)](https://coveralls.io/r/cucumber/cucumber-ruby?branch=main)
11
15
 
12
16
  Cucumber is a tool for running automated tests written in plain language. Because they're
13
17
  written in plain language, they can be read by anyone on your team. Because they can be
14
18
  read by anyone, you can use them to help improve communication, collaboration and trust on
15
19
  your team.
16
20
 
17
- Where to get more info:
21
+ <p align="center">
22
+ <img src="./.github/img/gherkin-example.png" alt="Cucumber Gherkin Example" width="728" />
23
+ </p>
24
+
25
+ This is the Ruby implementation of Cucumber. Cucumber is also available for [JavaScript](https://github.com/cucumber/cucumber-js),
26
+ [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/.
27
+
28
+ See [CONTRIBUTING.md](CONTRIBUTING.md) for info on contributing to Cucumber (issues, PRs, etc.).
29
+
30
+ Everyone interacting in this codebase and issue tracker is expected to follow the
31
+ Cucumber [code of conduct](https://cucumber.io/conduct).
32
+
33
+ ## Installation
34
+
35
+ Cucumber for Ruby is a Ruby gem. Install it as you would install any gem: add
36
+ `cucumber` to your Gemfile:
37
+
38
+ gem 'cucumber'
39
+
40
+ then install it:
41
+
42
+ $ bundle
43
+
44
+ or install the gem directly:
45
+
46
+ $ gem install cucumber
47
+
48
+ Later in this document, bundler is considered being used so all commands are using
49
+ `bundle exec`. If this is not the case for you, execute `cucumber` directly, without
50
+ `bundle exec`.
51
+
52
+ ### Supported platforms
53
+
54
+ - Ruby 3.1
55
+ - Ruby 3.0
56
+ - Ruby 2.7
57
+ - Ruby 2.6
58
+ - TruffleRuby 22.0.0+
59
+ - JRuby (with [some limitations](https://github.com/cucumber/cucumber-ruby/blob/main/docs/jruby-limitations.md))
60
+ - 9.3 >= 9.3.1 (there is a known issue with JRuby 9.3.0. More info can
61
+ be found in the [PR#1571](https://github.com/cucumber/cucumber-ruby/pull/1571).)
62
+
63
+ ### Ruby on Rails
64
+
65
+ Using Ruby on Rails? You can use [cucumber-rails](https://github.com/cucumber/cucumber-rails)
66
+ to bring Cucumber into your Rails project.
67
+
68
+ ## Usage
69
+
70
+ ### Initialization
71
+
72
+ If you need to, initialize your `features` directory with
73
+
74
+ $ bundle exec cucumber --init
75
+
76
+ This will create the following directories and files if they do not exist already:
77
+
78
+ features
79
+ ├── step_definitions
80
+ └── support
81
+ └── env.rb
82
+
83
+ ### Create your specification
84
+
85
+ Create a file named `rule.feature` in the `features` directory with:
86
+
87
+ ```gherkin
88
+ # features/rule.feature
89
+
90
+ Feature: Rule Sample
91
+
92
+ Rule: This is a rule
93
+
94
+ Example: A passing example
95
+ Given this will pass
96
+ When I do an action
97
+ Then some results should be there
98
+
99
+ Example: A failing example
100
+ Given this will fail
101
+ When I do an action
102
+ Then some results should be there
103
+
104
+ ```
105
+
106
+ ### Automate your specification
107
+
108
+ And a file named `steps.rb` in `features/step_definitions` with:
109
+
110
+ ```ruby
111
+ # features/step_definitions/steps.rb
112
+
113
+ Given("this will pass") do
114
+ @this_will_pass = true
115
+ end
116
+
117
+ Given("this will fail") do
118
+ @this_will_pass = false
119
+ end
120
+
121
+ When("I do an action") do
122
+ end
123
+
124
+ Then("some results should be there") do
125
+ expect(@this_will_pass)
126
+ end
127
+ ```
128
+
129
+ ### Run Cucumber
130
+
131
+ $ bundle exec cucumber
132
+
133
+ To execute a single feature file:
134
+
135
+ $ bundle exec cucumber features/rule.feature
136
+
137
+ To execute a single example, indicates the line of the name of the example:
138
+
139
+ $ bundle exec cucumber features/rule.feature:7
140
+
141
+ To summarize the results on the standard output, and writte a HTML report on disk:
142
+
143
+ $ bundle exec cucumber --format summary --format html --out report.html
18
144
 
19
- * The main website: https://cucumber.io/
20
- * Documentation: https://docs.cucumber.io
21
- * Ruby API Documentation: http://www.rubydoc.info/github/cucumber/cucumber-ruby/
22
- * Support forum: https://groups.google.com/group/cukes
23
- * Chat: ([Slack](https://cucumber.io/support#slack) and [Gitter](https://cucumber.io/support#gitter))
145
+ For more command line options
24
146
 
25
- See [CONTRIBUTING.md](CONTRIBUTING.md) for info on contributing to Cucumber.
147
+ $ bundle exec cucumber --help
26
148
 
27
- ## Supported platforms
28
- * Ruby 2.5
29
- * Ruby 2.4
30
- * Ruby 2.3
31
- * Ruby 2.2
32
- * JRuby 9.1
149
+ You can also find documentation on the command line possibilities in
150
+ [features/docs/cli](features/docs/cli).
33
151
 
34
- ## Code of Conduct
152
+ ## Documentation and support
35
153
 
36
- Everyone interacting in this codebase and issue tracker is expected to follow the Cucumber [code of conduct](https://github.com/cucumber/cucumber/blob/master/CODE_OF_CONDUCT.md).
154
+ - Getting started, writing features, step definitions, and more: https://cucumber.io/docs
155
+ - Ruby API Documentation: http://www.rubydoc.info/github/cucumber/cucumber-ruby/
156
+ - Community support forum: https://community.smartbear.com/t5/Cucumber-Open/bd-p/CucumberOS
157
+ - Slack: [register for an account](https://cucumberbdd-slack-invite.herokuapp.com/) then head over to [#intro](https://cucumberbdd.slack.com/messages/C5WD8SA21/)
37
158
 
38
159
  ## Copyright
39
160
 
data/bin/cucumber CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
  file_name = File.dirname(__FILE__) + '/../lib'
3
- $:.unshift(file_name) unless $:.include?(file_name)
3
+ $LOAD_PATH.unshift(file_name) unless $LOAD_PATH.include?(file_name)
4
4
 
5
5
  require 'simplecov_setup'
6
6
  require 'cucumber/rspec/disable_option_parser'
@@ -7,7 +7,7 @@ require 'cucumber/cli/profile_loader'
7
7
 
8
8
  module Autotest::CucumberMixin
9
9
  def self.included(receiver)
10
- receiver::ALL_HOOKS << [:run_features, :ran_features]
10
+ receiver::ALL_HOOKS << %i[run_features ran_features]
11
11
  end
12
12
 
13
13
  attr_accessor :features_to_run
@@ -23,26 +23,23 @@ module Autotest::CucumberMixin
23
23
  reset_features
24
24
  add_sigint_handler
25
25
 
26
- self.last_mtime = Time.now if $f
27
-
28
26
  loop do # ^c handler
29
- begin
30
- get_to_green
31
- if self.tainted then
32
- rerun_all_tests
33
- rerun_all_features if all_good
34
- else
35
- hook :all_good
36
- end
37
- wait_for_changes
38
- # Once tests and features are green, reset features every
39
- # time a file is changed to see if anything breaks.
40
- reset_features
41
- rescue Interrupt
42
- break if self.wants_to_quit
43
- reset
44
- reset_features
27
+ wait_for_green
28
+ if tainted
29
+ rerun_all_tests
30
+ rerun_all_features if all_good
31
+ else
32
+ hook :all_good
45
33
  end
34
+ wait_for_changes
35
+ # Once tests and features are green, reset features every
36
+ # time a file is changed to see if anything breaks.
37
+ reset_features
38
+ rescue Interrupt
39
+ break if wants_to_quit
40
+
41
+ reset
42
+ reset_features
46
43
  end
47
44
  hook :quit
48
45
  end
@@ -51,12 +48,13 @@ module Autotest::CucumberMixin
51
48
  features_to_run == ''
52
49
  end
53
50
 
54
- def get_to_green
55
- begin
51
+ def wait_for_green
52
+ loop do
56
53
  super
57
54
  run_features
58
55
  wait_for_changes unless all_features_good
59
- end until all_features_good
56
+ break if all_features_good
57
+ end
60
58
  end
61
59
 
62
60
  def rerun_all_features
@@ -71,67 +69,65 @@ module Autotest::CucumberMixin
71
69
  def run_features
72
70
  hook :run_features
73
71
  Tempfile.open('autotest-cucumber') do |dirty_features_file|
74
- cmd = self.make_cucumber_cmd(self.features_to_run, dirty_features_file.path)
72
+ cmd = make_cucumber_cmd(features_to_run, dirty_features_file.path)
75
73
  break if cmd.empty?
76
- puts cmd unless $q
74
+
77
75
  old_sync = $stdout.sync
78
76
  $stdout.sync = true
79
77
  self.results = []
80
78
  line = []
81
79
  begin
82
- open("| #{cmd}", 'r') do |f|
80
+ open("| #{cmd}", 'r') do |f| # rubocop:disable Security/Open
83
81
  until f.eof?
84
82
  c = f.getc || break
85
- if RUBY_VERSION >= '1.9' then
86
- print c
87
- else
88
- putc c
89
- end
83
+ print(c)
90
84
  line << c
91
- if c == ?\n then
92
- self.results << if RUBY_VERSION >= '1.9' then
93
- line.join
94
- else
95
- line.pack 'c*'
96
- end
97
- line.clear
98
- end
85
+ next unless c == "\n"
86
+
87
+ results << line.join
88
+ line.clear
99
89
  end
100
90
  end
101
91
  ensure
102
92
  $stdout.sync = old_sync
103
93
  end
104
94
  self.features_to_run = dirty_features_file.read.strip
105
- self.tainted = true unless self.features_to_run == ''
95
+ self.tainted = true unless features_to_run == ''
106
96
  end
107
97
  hook :ran_features
108
98
  end
109
99
 
110
- def make_cucumber_cmd(features_to_run, dirty_features_filename)
111
- return '' if features_to_run == ''
100
+ def make_cucumber_cmd(features_to_run, _dirty_features_filename)
101
+ return '' if features_to_run.empty?
112
102
 
113
103
  profile_loader = Cucumber::Cli::ProfileLoader.new
114
104
 
115
- profile ||= 'autotest-all' if profile_loader.has_profile?('autotest-all') && features_to_run == :all
116
- profile ||= 'autotest' if profile_loader.has_profile?('autotest')
117
- profile ||= nil
105
+ profile = profile(profile_loader)
106
+
107
+ args = created_args(features_to_run, profile)
118
108
 
109
+ "#{Cucumber::RUBY_BINARY} #{Cucumber::BINARY} #{args}"
110
+ end
111
+
112
+ def profile(profile_loader)
113
+ profile ||= 'autotest-all' if profile_loader.profile?('autotest-all') && features_to_run == :all
114
+ profile ||= 'autotest' if profile_loader.profile?('autotest')
115
+ profile || nil
116
+ end
117
+
118
+ def created_args(features_to_run, profile)
119
119
  args = if profile
120
120
  ['--profile', profile]
121
121
  else
122
- %w{--format} << (features_to_run == :all ? 'progress' : 'pretty')
122
+ %w[--format] << (features_to_run == :all ? 'progress' : 'pretty')
123
123
  end
124
124
  # No --color option as some IDEs (Netbeans) don't output them very well (1 failed step)
125
- args += %w{--format rerun --out} << dirty_features_filename
125
+ args += %w[--format rerun --out] << dirty_features_filename
126
126
  args << (features_to_run == :all ? '' : features_to_run)
127
127
 
128
- # Unless I do this, all the steps turn up undefined during the rerun...
129
- unless features_to_run == :all
130
- args << 'features/step_definitions' << 'features/support'
131
- end
132
-
133
- args = args.join(' ')
128
+ # All steps becom undefined during rerun unless the following is run.
129
+ args << 'features/step_definitions' << 'features/support' unless features_to_run == :all
134
130
 
135
- return "#{Cucumber::RUBY_BINARY} #{Cucumber::BINARY} #{args}"
131
+ args.join(' ')
136
132
  end
137
133
  end