cucumber-core 12.0.0 → 13.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5044df1d888874e71128efa080115becbb8c21a6e0ea79da117119b88390ae99
4
- data.tar.gz: a3a96cb3867f71c52f8cd430271f8751a8b819b3d195f027ca8573af4b537c6d
3
+ metadata.gz: 8be25fb56be8e8108a968aaf270b1e296df496b660a5d8536bb1c7cfe3e74359
4
+ data.tar.gz: e08583f1d1cfabd07ed42fb58ec6c0b4f3361d7b0c90286f29d26dbfd8bfb918
5
5
  SHA512:
6
- metadata.gz: ffab80fbb75922f2580383bdfa3747e1675dc524c945df0c94b5ae6146bd77907526ed81a049ea0a05b68cac5e5267ca0c698cc0b4483acd6e0428feedf4cbf8
7
- data.tar.gz: 4ee61046f1f49501db71e4a9d2792a4205c4fcd37da5481dd86cfe7a9be1fc01988a3ed5dc561332538969bd44cfa762d80712a6b4bc5d8594d24a9d24181932
6
+ metadata.gz: 1ad8d22710c9bff29cc1a4ab1a3d5cc41a4a10325aa25accdcde0a833489d4a0a6a98d9415452868551e312bc7672063ba89bf5f3929bc1448384c253a69768b
7
+ data.tar.gz: 14437bb84b31edf7bbad45cf1575770e90b907ccff5d284b89cb7b42aa9f3f5197f812a02dd762b3e121044dab6bc0a6fc4ecf322548267e56c8c7298b35e7c8
data/CHANGELOG.md CHANGED
@@ -1,287 +1,55 @@
1
1
  # Changelog
2
2
 
3
- ## [Unreleased]
4
-
5
- ## [12.0.0] - 2023-09-06
6
- ### Changed
7
- - Update gherkin and messages minimum dependencies
8
- - Added in new rubocop sub-gems for testing, pinning versions where appropriate
9
- - Removed all redundant / incorrect rubocop config overrides (Placed in TODO file)
10
-
11
- ### Removed
12
- - Remove support for ruby 2.4 and below. 2.5 or higher is required now
13
-
14
- ## [11.1.0] - 2022-12-22
15
- ### Changed
16
- - Update gherkin and messages dependencies
17
-
18
- ### Fixed
19
- - Restore support for matching a scenario by tag and step line numbers. ([#237](https://github.com/cucumber/cucumber-ruby-core/pull/237), [#238](https://github.com/cucumber/cucumber-ruby-core/pull/238), [#239](https://github.com/cucumber/cucumber-ruby-core/pull/239))
20
-
21
- ## [11.0.0]
22
- ### Changed
23
- - Updated `cucumber-gherkin` and `cucumber-messages`
3
+ All notable changes to this project will be documented in this file.
24
4
 
25
- ## [10.1.1]
26
- ### Changed
27
- - Patched `cucumber-tag-expressions`
5
+ This project adheres to [Semantic Versioning](http://semver.org).
28
6
 
29
- ## [10.1.0]
30
- ### Changed
31
- - Patched `cucumber-gherkin`, `cucumber-messages` and `cucumber-tag-expressions`
7
+ This document is formatted according to the principles of [Keep A CHANGELOG](http://keepachangelog.com).
32
8
 
33
- ## [10.0.1]
34
- ### Changed
35
- - Patched `cucumber-gherkin` and `cucumber-messages`
9
+ Please visit [cucumber/CONTRIBUTING.md](https://github.com/cucumber/cucumber/blob/master/CONTRIBUTING.md) for more info on how to contribute to Cucumber.
36
10
 
37
- ## [10.0.0]
38
- ### Changed
39
- - Upgraded to gherkin v20 and messages v17.
40
-
41
- ## [9.0.1]
42
- ### Fixed
43
- - Skipped scenarios do not affect anymore status of flaky scenarios on retry
44
- ([#218](https://github.com/cucumber/cucumber-ruby-core/pull/218) @eduardrudko)
11
+ ## [Unreleased]
45
12
 
46
- ## [9.0.0]
13
+ ## [13.0.0] - 2023-12-05
47
14
  ### Changed
48
- - Upgraded to gherkin v18 and messages v15
49
- - Updated other dependencies (look at the diff for details)
15
+ - Now using a 2-tiered changelog to avoid any bugs when using polyglot-release
16
+ - More refactoring of the repo by fixing up a bunch of manual rubocop offenses (See PR's for details)
17
+ ([#259](https://github.com/cucumber/cucumber-ruby-core/pull/259) [#262](https://github.com/cucumber/cucumber-ruby-core/pull/262) [#268](https://github.com/cucumber/cucumber-ruby-core/pull/268) [#274](https://github.com/cucumber/cucumber-ruby-core/pull/274))
18
+ - In all `Summary` and `Result` classes, changed the `strict` argument into a keyword argument
19
+ See upgrading notes for [13.0.0.md](upgrading_notes/13.0.0.md#upgrading-to-1300)
20
+ ([#261](https://github.com/cucumber/cucumber-ruby-core/pull/261))
21
+ - Permit usage of gherkin v27
50
22
 
51
- ## [8.0.1]
52
23
  ### Fixed
53
- - Make releases from docker using secrets from keybase
54
-
55
- ## [8.0.0]
56
- ### Changed
57
- - Updated dependencies (look at the diff for details)
58
-
59
- ## [7.1.0]
60
- ### Changed
61
- - `cucumber-gherkin` ~> 14.0.1
62
- - `cucumber-messages` ~> 12.2.0
63
- - Updated gems:
64
-
65
- ## [7.0.0]
66
- ### Changed
67
- - cucumber-gherkin ~> 13
68
- - cucumber-messages ~> 12
69
- - Updated monorepo libraries:
70
-
71
- ## [6.0.0]
72
- ### Added
73
- - Add `envelope` event, which are used when emitting `Cucumber::Messages`
74
- - Add `TestCaseCreated` and `TestStepCreated` events, emitted when compiling a `Pickle`
75
- - Add `Id` field to `TestCase` and `TestStep`
76
- - Added rubocop (with todo file), and removed backports gems
77
- ([#186](https://github.com/cucumber/cucumber-ruby-core/pull/186),
78
- [#182](https://github.com/cucumber/cucumber-ruby-core/issues/182)
79
- [tas50](https://github.com/tas50),
80
- [luke-hill](https://github.com/luke-hill))
81
-
82
- ### Changed
83
- - Update to Gherkin 10
24
+ - Restore support for matching a scenario by its Feature, Background, and Rule line numbers ([#247](https://github.com/cucumber/cucumber-ruby-core/pull/247))
84
25
 
85
26
  ### Removed
86
- - Remove location for MultiLine arguments
27
+ - Remove legacy `unindent` gem (Now no longer required since Ruby 2.3 and Squiggly heredocs) ([#278](https://github.com/cucumber/cucumber-ruby-core/pull/278))
87
28
 
88
- ## [5.0.2]
29
+ ## [12.0.0] - 2023-09-06
89
30
  ### Changed
90
- - Update to use Gherkin v8
31
+ - Update gherkin and messages minimum dependencies
32
+ - Added in new rubocop sub-gems for testing, pinning versions where appropriate
33
+ - Removed all redundant / incorrect rubocop config overrides (Placed in TODO file)
34
+ - Began to refactor the repo by initially fixing up a bunch of rubocop auto-fix offenses (See PRs for details)
35
+ ([#257](https://github.com/cucumber/cucumber-ruby-core/pull/257) [#258](https://github.com/cucumber/cucumber-ruby-core/pull/258))
91
36
 
92
- ## [5.0.1]
93
37
  ### Removed
94
- - Remove support for ruby 2.2 and below. 2.3 or higher is required now.
95
-
96
- ## [5.0.0]
97
- ### Changed
98
- - Update to use Gherkin v7
38
+ - Remove support for ruby 2.4 and below. 2.5 or higher is required now
99
39
 
100
- ## [4.0.0]
40
+ ## [11.1.0] - 2022-12-22
101
41
  ### Changed
102
- - Update to use Gherkin v6 ([#158](https://github.com/cucumber/cucumber-ruby-core/pull/158) @brasmusson)
103
- - Let Scenarios with no Steps get the result status Undefined ([#157](https://github.com/cucumber/cucumber-ruby-core/pull/157) @brasmusson)
104
- - Convert to use the Gherkin compiler and Pickles ([#156](https://github.com/cucumber/cucumber-ruby-core/pull/156) @brasmusson)
105
-
106
- ### Removed
107
- - Remove the support for old style tag expressions ([#159](https://github.com/cucumber/cucumber-ruby-core/pull/159) @brasmusson)
108
-
109
- ## [3.2.1]
110
- ### Fixed
111
- - Switched `gherkin` in Gemspec to use _pessimistic_ versioning. (These two commits aren't merged into `master`, as they already exist in newer commits. This is a 'backported' patch to resolve [#160](https://github.com/cucumber/cucumber-ruby-core/issues/160)).
112
-
113
- ## [3.2.0]
114
- ### Added
115
- - Add the GherkinSourceParsedEvent ([#155](https://github.com/cucumber/cucumber-ruby-core/pull/155) @brasmusson)
116
- - Add #original_location to Cucumber::Core::Ast::Step and Cucumber::Core::Test::Step ([#150](https://github.com/cucumber/cucumber-ruby-core/pull/150), [#149](https://github.com/cucumber/cucumber-ruby-core/issues/149) @brasmusson)
42
+ - Update gherkin and messages dependencies
117
43
 
118
44
  ### Fixed
119
- - Set message and backtrace for undefined result also when skipping (@brasmusson)
120
-
121
- ## [3.1.0]
122
- ### Changed
123
- - Upgraded to `cucumber-tag_expressions` 1.1.0
124
- - Upgraded to `gherkin` 5.0.0
125
-
126
- ## [3.0.0]
127
- ### Added
128
- - Do not create test cases for scenarios with no steps ([#144](https://github.com/cucumber/cucumber-ruby-core/pull/144) @brasmusson)
129
- - Handle selective strict settings ([#143](https://github.com/cucumber/cucumber-ruby-core/pull/143) @brasmusson)
45
+ - Restore support for matching a scenario by tag and step line numbers. ([#237](https://github.com/cucumber/cucumber-ruby-core/pull/237), [#238](https://github.com/cucumber/cucumber-ruby-core/pull/238), [#239](https://github.com/cucumber/cucumber-ruby-core/pull/239))
130
46
 
47
+ ## [11.0.0] - 2022-05-18
131
48
  ### Changed
132
- - Step#name renamed to #text ([#137](https://github.com/cucumber/cucumber-ruby-core/pull/137) [@olleolleolle](https://github.com/olleolleolle))
133
- - Use past tense in event names (`xStarting` -> `xStarted`) (see [cucumber/cucumber-ruby#1166](https://github.com/cucumber/cucumber-ruby/issues/1166) @brasmusson).
134
-
135
- ### Fixed
136
- - Fix DataTable's Location to be aware of all of its lines ([#142](https://github.com/cucumber/cucumber-ruby-core/pull/142) @botandrose)
137
- - As per [#251](https://github.com/cucumber/cucumber/issues/251): renamed History.md to CHANGELOG.md, added contributing message at beginning, and misc formatting. ([#145](https://github.com/cucumber/cucumber-ruby-core/pull/145) [jaysonesmith](https://github.com/jaysonesmith))
138
-
139
- ## [3.0.0.pre.2]
140
- ### Added
141
- - Add a flaky result type to be used for flaky scenarios ([#141](https://github.com/cucumber/cucumber-ruby-core/pull/141), [cucumber/cucumber-ruby#1044](https://github.com/cucumber/cucumber-ruby/issues/1044) @brasmusson)
142
- - Make the Summary report able to say if the total result is ok ([#140](https://github.com/cucumber/cucumber-ruby-core/pull/140) @brasmusson)
143
- - Replay previous events to new subscribers ([#136](https://github.com/cucumber/cucumber-ruby-core/pull/136) @mattwynne)
144
- - Ruby 2.4.0 compatibility ([#120](https://github.com/cucumber/cucumber-ruby-core/pull/120) @junaruga)
145
- - Use tag expressions ([#116](https://github.com/cucumber/cucumber-ruby-core/pull/116) @brasmusson)
146
- - Access example table row data by param name ([#118](https://github.com/cucumber/cucumber-ruby-core/pull/118) @enkessler)
147
-
148
- ### Fixed
149
- - Travis: jruby-9.1.10.0 ([#130](https://github.com/cucumber/cucumber-ruby-core/pull/130) @olleolleolle)
150
- - Travis: jruby-9.1.12.0 ([#133](https://github.com/cucumber/cucumber-ruby-core/pull/132) @olleolleolle)
151
-
152
- ## [2.0.0]
153
- ### Added
154
- - Implement equality for test cases ([#111](https://github.com/cucumber/cucumber-ruby-core/pull/111) @mattwynne)
155
- - Implement an event bus (moved from Cucumber-Ruby) ([#106](https://github.com/cucumber/cucumber-ruby-core/pull/106) @mattwynne)
156
- - Use frozen string literals ([#105](https://github.com/cucumber/cucumber-ruby-core/pull/105) @twalpole)
157
-
158
- ### Fixed
159
- - Handle incomplete examples to scenario outlines. ([109](https://github.com/cucumber/cucumber-ruby-core/pull/109) @brasmusson)
160
- - Add with_filtered_backtrace method to unknown result ([107](https://github.com/cucumber/cucumber-ruby-core/pull/107) @danascheider)
161
-
162
- ### Removed
163
- - Remove support for Ruby v1.9.3. ([112](https://github.com/cucumber/cucumber-ruby-core/pull/112) @brasmusson)
164
-
165
- ## [1.5.0]
166
- ### Added
167
- - Update to Gherkin v4.0 (@brasmusson)
168
-
169
- ### Fixed
170
- - Use monotonic time ([#103](https://github.com/cucumber/cucumber-ruby-core/pull/103) @mikz)
171
-
172
- ## [1.4.0]
173
- ### Added
174
- - Update to Gherkin v3.2.0 (@brasmusson)
175
-
176
- ### Fixed
177
-
178
- ## [1.3.1]
179
- ### Added
180
-
181
- ### Fixed
182
- - Speed up location filtering ([#99](https://github.com/cucumber/cucumber-ruby-core/issues/99) @mattwynne @akostadinov @brasmusson)
183
-
184
- ## [1.3.0]
185
- ### Added
186
- - Add factory method to Cucumber::Core::Ast::Location that uses the output from Proc#source_location (@brasmusson)
187
- - Integrate Gherkin3 parser (@brasmusson)
188
-
189
- ### Fixed
190
- - Make sure that `after_test_step` is sent also when a test step is interrupted by (a timeout in) an around hook ([cucumber/cucumber-ruby#909](https://github.com/cucumber/cucumber-ruby/issues/909) @brasmusson)
191
- - Improve the check that a test_step quacks like a Cucumber::Core::Test::Step ([95](https://github.com/cucumber/cucumber-ruby-core/issues/95) @brasmusson)
192
-
193
- ## [1.2.0]
194
- ### Added
195
- - Enable the location of actions to be the step or hook location (@brasmusson)
196
- - Add the comments to the Steps, Examples tables and Examples table rows Ast classes (@brasmusson)
197
- - Expose name, description and examples_rows attributes of `Ast::ExamplesTable` (@mattwynne)
198
- - Add #to_sym to Cucumber::Core::Test::Result classes ([#89](https://github.com/cucumber/cucumber-ruby-core/pull/89) @pdswan)
199
- - Add #ok? to Cucumber::Core::Test::Result classes ([#92](https://github.com/cucumber/cucumber-ruby-core/pull/92) @brasmusson)
200
-
201
- ### Fixed
202
-
203
- ## [1.1.3]
204
- ### Added
205
- - Added custom `inspect` methods for AST Nodes (@tooky)
206
-
207
- ## [1.1.2]
208
- ### Added
209
- - Make Test Case names for Scenario Outlines language neutral [83](https://github.com/cucumber/cucumber-ruby-core/pull/83) (@brasmusson)
210
- - Add predicate methods for Multline arguments (@mattwynne)
211
- - Expose `Test::Case#feature` (@mattwynne)
212
- - Fail test case if around hook fails (@mattwynne, @tooky)
213
- - Expose `Test::Case#around_hooks` (@tooky)
214
-
215
- ## [1.1.1]
216
- ### Added
217
- - Calculate actual keyword for snippets (@brasmusson)
218
-
219
- ### Fixed
220
- - Remove keyword from `Test::Case#name` [82](https://github.com/cucumber/cucumber-ruby-core/pull/82) (@richarda)
221
-
222
- ## [1.1.0]
223
- ### Added
224
- - LocationsFilter now sorts test cases as well as filtering them (@mattwynne)
225
-
226
- ## [1.0.0]
227
- ### Added
228
- - Added dynamic filter class constructor (@mattwynne)
229
-
230
- ## [1.0.0.beta.4]
231
- ### Added
232
- - Introduce a Duration object (#[71](https://github.com/cucumber/cucumber-ruby-core/pull/71) [@brasmusson](https://github.com/brasmusson))
233
- - BeforeStep hooks (#[70](https://github.com/cucumber/cucumber-ruby-core/pull/70) [@almostwhitehat](https://github.com/almostwhitehat))
234
- - Expose `Test::Case#test_steps` (@mattwynne)
235
-
236
- ### Fixed
237
- - Handle empty feature files (#[77](https://github.com/cucumber/cucumber-ruby-core/pull/77), [cucumber/cucumber-ruby#771](https://github.com/cucumber/cucumber-ruby/issues/771) [@brasmusson](https://github.com/brasmusson))
238
- - Run after hooks in reverse order (#[69](https://github.com/cucumber/cucumber-ruby-core/pull/69) [@erran](https://github.com/erran))
239
-
240
- ## [1.0.0.beta.3]
241
-
242
- ## [1.0.0.beta.2]
243
-
244
- ## [1.0.0.beta.3]
245
-
246
- ## [1.0.0.beta.2]
49
+ - Updated `cucumber-gherkin` and `cucumber-messages`
247
50
 
248
- [Unreleased]: https://github.com/cucumber/cucumber-ruby-core/compare/v10.1.1...main
249
- [12.0.0]: https://github.com/cucumber/cucumber-ruby-core/compare/v10.1.1...main
250
- [11.1.0]: https://github.com/cucumber/cucumber-ruby-core/compare/v10.1.1...main
51
+ [Unreleased]: https://github.com/cucumber/cucumber-ruby-core/compare/v13.0.0...HEAD
52
+ [13.0.0]: https://github.com/cucumber/cucumber-ruby-core/compare/v12.0.0...v13.0.0
53
+ [12.0.0]: https://github.com/cucumber/cucumber-ruby-core/compare/v11.1.0...v12.0.0
54
+ [11.1.0]: https://github.com/cucumber/cucumber-ruby-core/compare/v11.0.0...v11.1.0
251
55
  [11.0.0]: https://github.com/cucumber/cucumber-ruby-core/compare/v10.1.1...v11.0.0
252
- [10.1.1]: https://github.com/cucumber/cucumber-ruby-core/compare/v10.1.0...v10.1.1
253
- [10.1.0]: https://github.com/cucumber/cucumber-ruby-core/compare/v10.0.1...v10.1.0
254
- [10.0.1]: https://github.com/cucumber/cucumber-ruby-core/compare/v10.0.0...v10.0.1
255
- [10.0.0]: https://github.com/cucumber/cucumber-ruby-core/compare/v9.0.1...v10.0.0
256
- [9.0.1]: https://github.com/cucumber/cucumber-ruby-core/compare/v9.0.0...v9.0.1
257
- [9.0.0]: https://github.com/cucumber/cucumber-ruby-core/compare/v8.0.1...v9.0.0
258
- [8.0.1]: https://github.com/cucumber/cucumber-ruby-core/compare/v8.0.0...v8.0.1
259
- [8.0.0]: https://github.com/cucumber/cucumber-ruby-core/compare/v7.1.0...v8.0.0
260
- [7.1.0]: https://github.com/cucumber/cucumber-ruby-core/compare/v7.0.0...v7.1.0
261
- [7.0.0]: https://github.com/cucumber/cucumber-ruby-core/compare/v6.0.0...v7.0.0
262
- [6.0.0]: https://github.com/cucumber/cucumber-ruby-core/compare/v5.0.2...v6.0.0
263
- [5.0.2]: https://github.com/cucumber/cucumber-ruby-core/compare/v5.0.1...v5.0.2
264
- [5.0.1]: https://github.com/cucumber/cucumber-ruby-core/compare/v5.0.0...v5.0.1
265
- [5.0.0]: https://github.com/cucumber/cucumber-ruby-core/compare/v4.0.0...v5.0.0
266
- [4.0.0]: https://github.com/cucumber/cucumber-ruby-core/compare/v3.2.0...v4.0.0
267
- [3.2.1]: https://github.com/cucumber/cucumber-ruby-core/compare/v3.2.0...v3.2.1
268
- [3.2.0]: https://github.com/cucumber/cucumber-ruby-core/compare/v3.1.0...v3.2.0
269
- [3.1.0]: https://github.com/cucumber/cucumber-ruby-core/compare/v3.0.0...3.1.0
270
- [3.0.0]: https://github.com/cucumber/cucumber-ruby-core/compare/v3.0.0.pre.2...v3.0.0
271
- [3.0.0.pre.2]: https://github.com/cucumber/cucumber-ruby-core/compare/v2.0.0...3.0.0.pre.2
272
- [2.0.0]: https://github.com/cucumber/cucumber-ruby-core/compare/v1.5.0...2.0.0
273
- [1.5.0]: https://github.com/cucumber/cucumber-ruby-core/compare/v1.4.0...v1.5.0
274
- [1.4.0]: https://github.com/cucumber/cucumber-ruby-core/compare/v1.3.1...v1.4.0
275
- [1.3.1]: https://github.com/cucumber/cucumber-ruby-core/compare/v1.3.0...v1.3.1
276
- [1.3.0]: https://github.com/cucumber/cucumber-ruby-core/compare/v1.2.0...v1.3.0
277
- [1.2.0]: https://github.com/cucumber/cucumber-ruby-core/compare/v1.1.3...v1.2.0
278
- [1.1.3]: https://github.com/cucumber/cucumber-ruby-core/compare/v1.1.2...v1.1.3
279
- [1.1.2]: https://github.com/cucumber/cucumber-ruby-core/compare/v1.1.1...v1.1.2
280
- [1.1.1]: https://github.com/cucumber/cucumber-ruby-core/compare/v1.1.0...v1.1.1
281
- [1.1.0]: https://github.com/cucumber/cucumber-ruby-core/compare/v1.0.0...v1.1.0
282
- [1.0.0]: https://github.com/cucumber/cucumber-ruby-core/compare/v1.0.0.beta.4...v1.0.0
283
- [1.0.0.beta.4]: https://github.com/cucumber/cucumber-ruby-core/compare/v1.0.0.beta.3...v1.0.0.beta.4
284
- [1.0.0.beta.3]: https://github.com/cucumber/cucumber-ruby-core/compare/v1.0.0.beta.2...v1.0.0.beta.3
285
- [1.0.0.beta.2]: https://github.com/cucumber/cucumber-ruby-core/compare/v1.0.0.beta.1...v1.0.0.beta.2
286
- [1.0.0.beta.3]: https://github.com/cucumber/cucumber-ruby-core/compare/v1.0.0.beta.2...v1.0.0.beta.3
287
- [1.0.0.beta.2]: https://github.com/cucumber/cucumber-ruby-core/compare/v1.0.0.beta.1...v1.0.0.beta.2
@@ -37,17 +37,18 @@ module Cucumber
37
37
  def create_test_case(pickle)
38
38
  uri = pickle.uri
39
39
  test_steps = pickle.steps.map { |step| create_test_step(step, uri) }
40
- lines = source_lines_for_pickle(pickle).sort.reverse
41
- tags = pickle.tags.map { |tag| Test::Tag.new(Test::Location.new(uri, source_line_for_pickle_tag(tag)), tag.name) }
42
- test_case = Test::Case.new(id_generator.new_id, pickle.name, test_steps, Test::Location.new(uri, lines), tags, pickle.language)
40
+ location = location_from_pickle(pickle)
41
+ parent_locations = parent_locations_from_pickle(pickle)
42
+ tags = tags_from_pickle(pickle, uri)
43
+ test_case = Test::Case.new(id_generator.new_id, pickle.name, test_steps, location, parent_locations, tags, pickle.language)
43
44
  @event_bus&.test_case_created(test_case, pickle)
44
45
  test_case
45
46
  end
46
47
 
47
48
  def create_test_step(pickle_step, uri)
48
- lines = source_lines_for_pickle_step(pickle_step).sort.reverse
49
+ location = location_from_pickle_step(pickle_step, uri)
49
50
  multiline_arg = create_multiline_arg(pickle_step, uri)
50
- step = Test::Step.new(id_generator.new_id, pickle_step.text, Test::Location.new(uri, lines), multiline_arg)
51
+ step = Test::Step.new(id_generator.new_id, pickle_step.text, location, multiline_arg)
51
52
  @event_bus&.test_step_created(step, pickle_step)
52
53
  step
53
54
  end
@@ -55,37 +56,57 @@ module Cucumber
55
56
  def create_multiline_arg(pickle_step, _uri)
56
57
  if pickle_step.argument
57
58
  if pickle_step.argument.doc_string
58
- doc_string = pickle_step.argument.doc_string
59
- Test::DocString.new(
60
- doc_string.content,
61
- doc_string.media_type
62
- )
59
+ doc_string_from_pickle_step(pickle_step)
63
60
  elsif pickle_step.argument.data_table
64
- data_table = pickle_step.argument.data_table
65
- Test::DataTable.new(
66
- data_table.rows.map { |row| row.cells.map { |cell| cell.value } }
67
- )
61
+ data_table_from_pickle_step(pickle_step)
68
62
  end
69
63
  else
70
64
  Test::EmptyMultilineArgument.new
71
65
  end
72
66
  end
73
67
 
74
- def source_lines_for_pickle(pickle)
75
- pickle.ast_node_ids.map { |id| source_line(id) }
68
+ def location_from_pickle(pickle)
69
+ lines = pickle.ast_node_ids.map { |id| source_line(id) }
70
+ Test::Location.new(pickle.uri, lines.sort.reverse)
76
71
  end
77
72
 
78
- def source_lines_for_pickle_step(pickle_step)
79
- pickle_step.ast_node_ids.map { |id| source_line(id) }
73
+ def parent_locations_from_pickle(pickle)
74
+ parent_lines = gherkin_query.scenario_parent_locations(pickle.ast_node_ids[0]).map(&:line)
75
+ Test::Location.new(pickle.uri, parent_lines)
80
76
  end
81
77
 
82
- def source_line_for_pickle_tag(tag)
83
- source_line(tag.ast_node_id)
78
+ def location_from_pickle_step(pickle_step, uri)
79
+ lines = pickle_step.ast_node_ids.map { |id| source_line(id) }
80
+ Test::Location.new(uri, lines.sort.reverse)
81
+ end
82
+
83
+ def tags_from_pickle(pickle, uri)
84
+ pickle.tags.map do |tag|
85
+ location = Test::Location.new(uri, source_line(tag.ast_node_id))
86
+ Test::Tag.new(location, tag.name)
87
+ end
84
88
  end
85
89
 
86
90
  def source_line(id)
87
91
  gherkin_query.location(id).line
88
92
  end
93
+
94
+ def doc_string_from_pickle_step(pickle_step)
95
+ doc_string = pickle_step.argument.doc_string
96
+ Test::DocString.new(
97
+ doc_string.content,
98
+ doc_string.media_type
99
+ )
100
+ end
101
+
102
+ def data_table_from_pickle_step(pickle_step)
103
+ data_table = pickle_step.argument.data_table
104
+ Test::DataTable.new(
105
+ data_table.rows.map do |row|
106
+ row.cells.map(&:value)
107
+ end
108
+ )
109
+ end
89
110
  end
90
111
  end
91
112
  end
@@ -1,61 +1,60 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Cucumber
2
4
  module Core
3
5
  class Event
4
-
5
6
  # Macro to generate new sub-classes of {Event} with
6
7
  # attribute readers.
7
- def self.new(*attributes)
8
+ def self.new(*events)
8
9
  # Use normal constructor for subclasses of Event
9
- return super if self.ancestors.index(Event) > 0
10
+ return super if ancestors.index(Event) > 0
10
11
 
11
12
  Class.new(Event) do
12
- attr_reader(*attributes)
13
-
14
- define_method(:initialize) do |*args|
15
- attributes.zip(args) do |name, value|
16
- instance_variable_set "@#{name}".to_sym, value
13
+ # NB: We need to use metaprogramming here instead of direct variable obtainment
14
+ # because JRuby does not guarantee the order in which variables are defined is equivalent
15
+ # to the order in which they are obtainable
16
+ #
17
+ # See https://github.com/jruby/jruby/issues/7988 for more info
18
+ attr_reader(*events)
19
+
20
+ define_method(:initialize) do |*attributes|
21
+ events.zip(attributes) do |name, value|
22
+ instance_variable_set("@#{name}".to_sym, value)
17
23
  end
18
24
  end
19
25
 
20
26
  define_method(:attributes) do
21
- attributes.map { |attribute| self.send(attribute) }
27
+ events.map { |var| instance_variable_get(:"@#{var}") }
22
28
  end
23
29
 
24
30
  define_method(:to_h) do
25
- attributes.reduce({}) { |result, attribute|
26
- value = self.send(attribute)
27
- result[attribute] = value
28
- result
29
- }
31
+ events.zip(attributes).to_h
30
32
  end
31
33
 
32
- define_method(:event_id) do
34
+ def event_id
33
35
  self.class.event_id
34
36
  end
35
37
  end
36
38
  end
37
39
 
38
-
39
40
  class << self
40
-
41
- # @return [Symbol] the underscored name of the class to be used
42
- #  as the key in an event registry.
41
+ # @return [Symbol] the underscored name of the class to be used as the key in an event registry
43
42
  def event_id
44
- underscore(self.name.split("::").last).to_sym
43
+ underscore(name.split('::').last).to_sym
45
44
  end
46
45
 
47
46
  private
48
47
 
49
48
  def underscore(string)
50
- string.to_s.gsub('::', '/').
51
- gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2').
52
- gsub(/([a-z\d])([A-Z])/, '\1_\2').
53
- tr("-", "_").
54
- downcase
49
+ string
50
+ .to_s
51
+ .gsub('::', '/').
52
+ gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2').
53
+ gsub(/([a-z\d])([A-Z])/, '\1_\2').
54
+ tr('-', '_').
55
+ downcase
55
56
  end
56
-
57
57
  end
58
-
59
58
  end
60
59
  end
61
60
  end
@@ -1,13 +1,13 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'cucumber/core/events'
2
4
 
3
5
  module Cucumber
4
6
  module Core
5
-
6
7
  # Event Bus
7
8
  #
8
9
  # Implements an in-process pub-sub event broadcaster allowing multiple observers
9
10
  # to subscribe to events that fire as your tests are executed.
10
- #
11
11
  class EventBus
12
12
  attr_reader :event_types
13
13
 
@@ -18,8 +18,7 @@ module Cucumber
18
18
  @event_queue = []
19
19
  end
20
20
 
21
- # Register for an event. The handler proc will be called back with each of the attributes
22
- # of the event.
21
+ # Register for an event. The handler proc will be called back with each of the attributes of the event
23
22
  def on(event_id, handler_object = nil, &handler_proc)
24
23
  handler = handler_proc || handler_object
25
24
  validate_handler_and_event_id!(handler, event_id)
@@ -28,9 +27,8 @@ module Cucumber
28
27
  broadcast_queued_events_to handler, event_class
29
28
  end
30
29
 
31
- # Broadcast an event
32
30
  def broadcast(event)
33
- raise ArgumentError, "Event type #{event.class} is not registered. Try one of these:\n#{event_types.values.join("\n")}" unless is_registered_type?(event.class)
31
+ raise ArgumentError, "Event type #{event.class} is not registered. Try one of these:\n#{event_types.values.join("\n")}" unless registered_type?(event.class)
34
32
  handlers_for(event.class).each { |handler| handler.call(event) }
35
33
  @event_queue << event
36
34
  end
@@ -40,34 +38,33 @@ module Cucumber
40
38
  broadcast event_class.new(*args)
41
39
  end
42
40
 
41
+ def respond_to_missing?(event_id, *args)
42
+ event_types.key?(event_id) || super
43
+ end
44
+
43
45
  private
44
46
 
45
47
  def broadcast_queued_events_to(handler, event_type)
46
- @event_queue.select { |event|
47
- event.instance_of?(event_type)
48
- }.each { |event|
49
- handler.call(event)
50
- }
48
+ @event_queue.select { |event| event.instance_of?(event_type) }.each { |event| handler.call(event) }
51
49
  end
52
50
 
53
51
  def handlers_for(event_class)
54
52
  @handlers[event_class.to_s] ||= []
55
53
  end
56
54
 
57
- def is_registered_id?(event_id)
58
- event_types.keys.include?(event_id)
55
+ def registered_type?(event_type)
56
+ event_types.values.include?(event_type)
59
57
  end
60
58
 
61
- def is_registered_type?(event_type)
62
- event_types.values.include?(event_type)
59
+ def registered_id?(event_id)
60
+ event_types.keys.include?(event_id)
63
61
  end
64
62
 
65
63
  def validate_handler_and_event_id!(handler, event_id)
66
- raise ArgumentError, "Please pass either an object or a handler block" unless handler
67
- raise ArgumentError, "Please use a symbol for the event_id" unless event_id.is_a?(Symbol)
68
- raise ArgumentError, "Event ID #{event_id} is not recognised. Try one of these:\n#{event_types.keys.join("\n")}" unless is_registered_id?(event_id)
64
+ raise ArgumentError, 'Please pass either an object or a handler block' unless handler
65
+ raise ArgumentError, 'Please use a symbol for the event_id' unless event_id.is_a?(Symbol)
66
+ raise ArgumentError, "Event ID #{event_id} is not recognised. Try one of these:\n#{event_types.keys.join("\n")}" unless registered_id?(event_id)
69
67
  end
70
68
  end
71
-
72
69
  end
73
70
  end