cucumber-cucumber-expressions 17.0.1 → 17.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (26) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +13 -3
  3. data/.rubocop_todo.yml +60 -141
  4. data/VERSION +1 -1
  5. data/cucumber-cucumber-expressions.gemspec +9 -4
  6. data/lib/cucumber/cucumber_expressions/combinatorial_generated_expression_factory.rb +1 -1
  7. data/lib/cucumber/cucumber_expressions/cucumber_expression.rb +8 -8
  8. data/lib/cucumber/cucumber_expressions/cucumber_expression_parser.rb +1 -1
  9. data/lib/cucumber/cucumber_expressions/errors.rb +11 -11
  10. data/lib/cucumber/cucumber_expressions/parameter_type.rb +1 -3
  11. data/lib/cucumber/cucumber_expressions/parameter_type_matcher.rb +2 -2
  12. data/spec/cucumber/cucumber_expressions/argument_spec.rb +1 -1
  13. data/spec/cucumber/cucumber_expressions/combinatorial_generated_expression_factory_spec.rb +41 -0
  14. data/spec/cucumber/cucumber_expressions/cucumber_expression_generator_spec.rb +10 -10
  15. data/spec/cucumber/cucumber_expressions/cucumber_expression_parser_spec.rb +1 -1
  16. data/spec/cucumber/cucumber_expressions/cucumber_expression_spec.rb +8 -8
  17. data/spec/cucumber/cucumber_expressions/cucumber_expression_tokenizer_spec.rb +2 -2
  18. data/spec/cucumber/cucumber_expressions/cucumber_expression_transformation_spec.rb +2 -2
  19. data/spec/cucumber/cucumber_expressions/custom_parameter_type_spec.rb +7 -7
  20. data/spec/cucumber/cucumber_expressions/expression_factory_spec.rb +1 -1
  21. data/spec/cucumber/cucumber_expressions/parameter_type_registry_spec.rb +11 -11
  22. data/spec/cucumber/cucumber_expressions/parameter_type_spec.rb +1 -1
  23. data/spec/cucumber/cucumber_expressions/regular_expression_spec.rb +2 -2
  24. data/spec/cucumber/cucumber_expressions/tree_regexp_spec.rb +26 -27
  25. metadata +62 -6
  26. data/spec/cucumber/cucumber_expressions/combinatorial_generated_expression_factory_test.rb +0 -44
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cf1302afcc82ce4965f46efebeeea9315e680395bc915142f572ee1f025eecb0
4
- data.tar.gz: 06d986ddaaaed001bd00e82059eb685cbb6507241b64b6081905c4373d620e96
3
+ metadata.gz: 6b49e9f64d889645dcee283e717f9b6c268293166219700c1e95435ce318e6f6
4
+ data.tar.gz: eda9b64c55c72304d1fa7d8509f16a9f5eb9c347cbf38125c41a3bbbf8d61f1f
5
5
  SHA512:
6
- metadata.gz: 4ca20260b78e485d7d5f3d085529843c7195a53c0289464b9d02f782bcd1431153dbfc5df1e58ea7c02432d04a9df8d7a60b648f31f4736632697efa1f9addd6
7
- data.tar.gz: a66a69755c51e1d1e154ac51230e9f8b784b86a3336ba4b6f87c04c4fc445081bef66c733954ed76d908433ef8648fcff8e5805c5ea01a22d5e2ca1490f4ce21
6
+ metadata.gz: 38a2e12bed97250bb03688aef8fcb596d78be09229ba5c33c7aee2957596b35f92abecd8a2fa6cc7b946ea7f05b9a9cd585dd4168898a38d3bc4aeb500ae8df1
7
+ data.tar.gz: a75778aa75c97f1e110e5d03725ae0a447429f2b1aac28bb5c7d947803ef95b4a38e23730f6d98459050bcd7c4cbae80e08a8c10b1a215d77ef537ca2319ff90
data/.rubocop.yml CHANGED
@@ -1,3 +1,8 @@
1
+ require:
2
+ - rubocop-performance
3
+ - rubocop-rake
4
+ - rubocop-rspec
5
+
1
6
  inherit_from: .rubocop_todo.yml
2
7
 
3
8
  inherit_mode:
@@ -15,6 +20,12 @@ Gemspec/RequireMFA:
15
20
  Layout/LineLength:
16
21
  Max: 200
17
22
 
23
+ # This is documented in this spec to showcase why it's not working and people shouldn't use it
24
+ # cf:
25
+ Lint/MixedRegexpCaptureTypes:
26
+ Exclude:
27
+ - 'spec/cucumber/cucumber_expressions/tree_regexp_spec.rb'
28
+
18
29
  Style/Documentation:
19
30
  Enabled: false
20
31
 
@@ -22,6 +33,5 @@ Style/RegexpLiteral:
22
33
  EnforcedStyle: slashes
23
34
  AllowInnerSlashes: true
24
35
 
25
- # Once we enable rubocop-rspec
26
- #RSpec/MessageSpies:
27
- # EnforcedStyle: receive
36
+ RSpec/MessageSpies:
37
+ EnforcedStyle: receive
data/.rubocop_todo.yml CHANGED
@@ -1,6 +1,6 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2023-10-06 11:04:10 UTC using RuboCop version 1.27.0.
3
+ # on 2023-11-27 17:52:56 UTC using RuboCop version 1.27.0.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
@@ -8,90 +8,14 @@
8
8
 
9
9
  # TODO: Oct '23 -> 33 files inspected, 1004 offenses detected, 859 offenses auto-correctable
10
10
  # TODO: Oct '23 (later) -> 33 files inspected, 344 offenses detected, 205 offenses auto-correctable
11
-
12
- # Offense count: 1
13
- # This cop supports safe auto-correction (--auto-correct).
14
- # Configuration parameters: EnforcedStyle, IndentationWidth.
15
- # SupportedStyles: outdent, indent
16
- Layout/AccessModifierIndentation:
17
- Exclude:
18
- - 'lib/cucumber/cucumber_expressions/cucumber_expression_generator.rb'
11
+ # TODO: Nov '23 -> 33 files inspected, 399 offenses detected, 192 offenses auto-correctable
19
12
 
20
13
  # Offense count: 2
21
14
  # This cop supports safe auto-correction (--auto-correct).
22
- # Configuration parameters: EnforcedStyle, IndentationWidth.
15
+ # Configuration parameters: IndentationWidth.
23
16
  # SupportedStyles: special_inside_parentheses, consistent, align_brackets
24
17
  Layout/FirstArrayElementIndentation:
25
- Exclude:
26
- - 'spec/cucumber/cucumber_expressions/combinatorial_generated_expression_factory_test.rb'
27
-
28
- # Offense count: 2
29
- # This cop supports safe auto-correction (--auto-correct).
30
- # Configuration parameters: EnforcedStyle, IndentationWidth.
31
- # SupportedStyles: special_inside_parentheses, consistent, align_braces
32
- Layout/FirstHashElementIndentation:
33
- Exclude:
34
- - 'cucumber-cucumber-expressions.gemspec'
35
-
36
- # Offense count: 4
37
- # This cop supports safe auto-correction (--auto-correct).
38
- # Configuration parameters: AllowMultipleStyles, EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle.
39
- # SupportedHashRocketStyles: key, separator, table
40
- # SupportedColonStyles: key, separator, table
41
- # SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit
42
- Layout/HashAlignment:
43
- Exclude:
44
- - 'cucumber-cucumber-expressions.gemspec'
45
-
46
- # Offense count: 2
47
- # This cop supports safe auto-correction (--auto-correct).
48
- # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
49
- # URISchemes: http, https
50
- Layout/LineLength:
51
- Max: 252
52
-
53
- # Offense count: 1
54
- # This cop supports safe auto-correction (--auto-correct).
55
- # Configuration parameters: EnforcedStyle.
56
- # SupportedStyles: symmetrical, new_line, same_line
57
- Layout/MultilineMethodCallBraceLayout:
58
- Exclude:
59
- - 'spec/cucumber/cucumber_expressions/parameter_type_spec.rb'
60
-
61
- # Offense count: 3
62
- # This cop supports safe auto-correction (--auto-correct).
63
- # Configuration parameters: EnforcedStyle, IndentationWidth.
64
- # SupportedStyles: aligned, indented, indented_relative_to_receiver
65
- Layout/MultilineMethodCallIndentation:
66
- Exclude:
67
- - 'lib/cucumber/cucumber_expressions/cucumber_expression_generator.rb'
68
-
69
- # Offense count: 4
70
- # This cop supports safe auto-correction (--auto-correct).
71
- # Configuration parameters: AllowForAlignment, EnforcedStyleForExponentOperator.
72
- # SupportedStylesForExponentOperator: space, no_space
73
- Layout/SpaceAroundOperators:
74
- Exclude:
75
- - 'lib/cucumber/cucumber_expressions/tree_regexp.rb'
76
-
77
- # Offense count: 57
78
- # This cop supports safe auto-correction (--auto-correct).
79
- # Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters.
80
- # SupportedStyles: space, no_space
81
- # SupportedStylesForEmptyBraces: space, no_space
82
- Layout/SpaceInsideBlockBraces:
83
- Exclude:
84
- - 'cucumber-cucumber-expressions.gemspec'
85
- - 'lib/cucumber/cucumber_expressions/group_builder.rb'
86
- - 'lib/cucumber/cucumber_expressions/parameter_type_registry.rb'
87
- - 'lib/cucumber/cucumber_expressions/regular_expression.rb'
88
- - 'spec/cucumber/cucumber_expressions/combinatorial_generated_expression_factory_test.rb'
89
- - 'spec/cucumber/cucumber_expressions/cucumber_expression_generator_spec.rb'
90
- - 'spec/cucumber/cucumber_expressions/cucumber_expression_tokenizer_spec.rb'
91
- - 'spec/cucumber/cucumber_expressions/custom_parameter_type_spec.rb'
92
- - 'spec/cucumber/cucumber_expressions/parameter_type_registry_spec.rb'
93
- - 'spec/cucumber/cucumber_expressions/parameter_type_spec.rb'
94
- - 'spec/cucumber/cucumber_expressions/tree_regexp_spec.rb'
18
+ EnforcedStyle: consistent
95
19
 
96
20
  # Offense count: 1
97
21
  # This cop supports safe auto-correction (--auto-correct).
@@ -114,47 +38,27 @@ Lint/DuplicateBranch:
114
38
  - 'lib/cucumber/cucumber_expressions/ast.rb'
115
39
  - 'lib/cucumber/cucumber_expressions/cucumber_expression_parser.rb'
116
40
 
117
- # Offense count: 10
41
+ # Offense count: 5
118
42
  # Configuration parameters: AllowComments.
119
43
  Lint/EmptyClass:
120
44
  Exclude:
121
- - 'spec/cucumber/cucumber_expressions/combinatorial_generated_expression_factory_test.rb'
122
45
  - 'spec/cucumber/cucumber_expressions/cucumber_expression_generator_spec.rb'
123
46
  - 'spec/cucumber/cucumber_expressions/cucumber_expression_spec.rb'
124
47
  - 'spec/cucumber/cucumber_expressions/parameter_type_registry_spec.rb'
125
48
 
126
- # Offense count: 1
127
- Lint/MixedRegexpCaptureTypes:
128
- Exclude:
129
- - 'spec/cucumber/cucumber_expressions/tree_regexp_spec.rb'
130
-
131
49
  # Offense count: 1
132
50
  # This cop supports unsafe auto-correction (--auto-correct-all).
133
51
  Lint/NonDeterministicRequireOrder:
134
52
  Exclude:
135
53
  - 'Rakefile'
136
54
 
137
- # Offense count: 1
138
- Lint/NonLocalExitFromIterator:
139
- Exclude:
140
- - 'lib/cucumber/cucumber_expressions/combinatorial_generated_expression_factory.rb'
141
-
142
- # Offense count: 7
55
+ # Offense count: 5
143
56
  # Configuration parameters: AllowKeywordBlockArguments.
144
57
  Lint/UnderscorePrefixedVariableName:
145
58
  Exclude:
146
- - 'lib/cucumber/cucumber_expressions/ast.rb'
147
59
  - 'lib/cucumber/cucumber_expressions/cucumber_expression_parser.rb'
148
60
  - 'lib/cucumber/cucumber_expressions/group.rb'
149
61
 
150
- # Offense count: 14
151
- # This cop supports safe auto-correction (--auto-correct).
152
- # Configuration parameters: IgnoreEmptyBlocks, AllowUnusedKeywordArguments.
153
- Lint/UnusedBlockArgument:
154
- Exclude:
155
- - 'spec/cucumber/cucumber_expressions/combinatorial_generated_expression_factory_test.rb'
156
- - 'spec/cucumber/cucumber_expressions/parameter_type_registry_spec.rb'
157
-
158
62
  # Offense count: 10
159
63
  # Configuration parameters: IgnoredMethods, CountRepeatedAttributes.
160
64
  Metrics/AbcSize:
@@ -201,21 +105,6 @@ Metrics/ParameterLists:
201
105
  Metrics/PerceivedComplexity:
202
106
  Max: 17
203
107
 
204
- # Offense count: 10
205
- # Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames.
206
- Naming/BlockParameterName:
207
- Exclude:
208
- - 'lib/cucumber/cucumber_expressions/cucumber_expression.rb'
209
- - 'lib/cucumber/cucumber_expressions/cucumber_expression_parser.rb'
210
- - 'lib/cucumber/cucumber_expressions/parameter_type_matcher.rb'
211
-
212
- # Offense count: 2
213
- # Configuration parameters: ForbiddenDelimiters.
214
- # ForbiddenDelimiters: (?-mix:(^|\s)(EO[A-Z]{1}|END)(\s|$))
215
- Naming/HeredocDelimiterNaming:
216
- Exclude:
217
- - 'lib/cucumber/cucumber_expressions/errors.rb'
218
-
219
108
  # Offense count: 7
220
109
  # Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames.
221
110
  # AllowedNames: at, by, db, id, in, io, ip, of, on, os, pp, to
@@ -238,14 +127,59 @@ Naming/PredicateName:
238
127
  - 'lib/cucumber/cucumber_expressions/parameter_type.rb'
239
128
  - 'lib/cucumber/cucumber_expressions/tree_regexp.rb'
240
129
 
241
- # Offense count: 20
242
- # Configuration parameters: EnforcedStyle, AllowedIdentifiers.
243
- # SupportedStyles: snake_case, camelCase
244
- Naming/VariableName:
130
+ # Offense count: 3
131
+ # This cop supports safe auto-correction (--auto-correct).
132
+ Performance/RedundantBlockCall:
245
133
  Exclude:
246
134
  - 'lib/cucumber/cucumber_expressions/cucumber_expression.rb'
247
- - 'lib/cucumber/cucumber_expressions/cucumber_expression_parser.rb'
248
- - 'lib/cucumber/cucumber_expressions/parameter_type_matcher.rb'
135
+
136
+ # Offense count: 2
137
+ # Configuration parameters: Prefixes.
138
+ # Prefixes: when, with, without
139
+ RSpec/ContextWording:
140
+ Exclude:
141
+ - 'spec/cucumber/cucumber_expressions/cucumber_expression_generator_spec.rb'
142
+
143
+ # Offense count: 29
144
+ # Configuration parameters: Max.
145
+ RSpec/ExampleLength:
146
+ Exclude:
147
+ - 'spec/cucumber/cucumber_expressions/combinatorial_generated_expression_factory_spec.rb'
148
+ - 'spec/cucumber/cucumber_expressions/cucumber_expression_generator_spec.rb'
149
+ - 'spec/cucumber/cucumber_expressions/cucumber_expression_parser_spec.rb'
150
+ - 'spec/cucumber/cucumber_expressions/cucumber_expression_spec.rb'
151
+ - 'spec/cucumber/cucumber_expressions/cucumber_expression_tokenizer_spec.rb'
152
+ - 'spec/cucumber/cucumber_expressions/cucumber_expression_transformation_spec.rb'
153
+ - 'spec/cucumber/cucumber_expressions/custom_parameter_type_spec.rb'
154
+ - 'spec/cucumber/cucumber_expressions/parameter_type_registry_spec.rb'
155
+ - 'spec/cucumber/cucumber_expressions/parameter_type_spec.rb'
156
+ - 'spec/cucumber/cucumber_expressions/regular_expression_spec.rb'
157
+ - 'spec/cucumber/cucumber_expressions/tree_regexp_spec.rb'
158
+
159
+ # Offense count: 3
160
+ RSpec/LeakyConstantDeclaration:
161
+ Exclude:
162
+ - 'spec/cucumber/cucumber_expressions/cucumber_expression_generator_spec.rb'
163
+ - 'spec/cucumber/cucumber_expressions/cucumber_expression_spec.rb'
164
+
165
+ # Offense count: 34
166
+ RSpec/MultipleExpectations:
167
+ Max: 30
168
+
169
+ # Offense count: 1
170
+ # Configuration parameters: AllowSubject.
171
+ RSpec/MultipleMemoizedHelpers:
172
+ Max: 6
173
+
174
+ # Offense count: 2
175
+ RSpec/RepeatedDescription:
176
+ Exclude:
177
+ - 'spec/cucumber/cucumber_expressions/tree_regexp_spec.rb'
178
+
179
+ # Offense count: 2
180
+ RSpec/RepeatedExample:
181
+ Exclude:
182
+ - 'spec/cucumber/cucumber_expressions/tree_regexp_spec.rb'
249
183
 
250
184
  # Offense count: 2
251
185
  # Configuration parameters: EnforcedStyle, AllowModifiersOnSymbols.
@@ -254,7 +188,7 @@ Style/AccessModifierDeclarations:
254
188
  Exclude:
255
189
  - 'lib/cucumber/cucumber_expressions/tree_regexp.rb'
256
190
 
257
- # Offense count: 5
191
+ # Offense count: 4
258
192
  # This cop supports safe auto-correction (--auto-correct).
259
193
  # Configuration parameters: EnforcedStyle, ProceduralMethods, FunctionalMethods, IgnoredMethods, AllowBracesOnProceduralOneLiners, BracesRequiredMethods.
260
194
  # SupportedStyles: line_count_based, semantic, braces_for_chaining, always_braces
@@ -267,7 +201,6 @@ Style/BlockDelimiters:
267
201
  - 'spec/cucumber/cucumber_expressions/cucumber_expression_spec.rb'
268
202
  - 'spec/cucumber/cucumber_expressions/cucumber_expression_transformation_spec.rb'
269
203
  - 'spec/cucumber/cucumber_expressions/custom_parameter_type_spec.rb'
270
- - 'spec/cucumber/cucumber_expressions/tree_regexp_spec.rb'
271
204
 
272
205
  # Offense count: 1
273
206
  # This cop supports unsafe auto-correction (--auto-correct-all).
@@ -378,12 +311,6 @@ Style/ParallelAssignment:
378
311
  - 'lib/cucumber/cucumber_expressions/parameter_type_matcher.rb'
379
312
  - 'spec/cucumber/cucumber_expressions/custom_parameter_type_spec.rb'
380
313
 
381
- # Offense count: 1
382
- # This cop supports safe auto-correction (--auto-correct).
383
- Style/PerlBackrefs:
384
- Exclude:
385
- - 'lib/cucumber/cucumber_expressions/parameter_type.rb'
386
-
387
314
  # Offense count: 1
388
315
  # This cop supports unsafe auto-correction (--auto-correct-all).
389
316
  # Configuration parameters: EnforcedStyle.
@@ -473,7 +400,7 @@ Style/SymbolProc:
473
400
  - 'lib/cucumber/cucumber_expressions/ast.rb'
474
401
  - 'lib/cucumber/cucumber_expressions/cucumber_expression_parser.rb'
475
402
  - 'lib/cucumber/cucumber_expressions/errors.rb'
476
- - 'spec/cucumber/cucumber_expressions/combinatorial_generated_expression_factory_test.rb'
403
+ - 'spec/cucumber/cucumber_expressions/combinatorial_generated_expression_factory_spec.rb'
477
404
  - 'spec/cucumber/cucumber_expressions/cucumber_expression_tokenizer_spec.rb'
478
405
  - 'spec/cucumber/cucumber_expressions/tree_regexp_spec.rb'
479
406
 
@@ -484,7 +411,7 @@ Style/SymbolProc:
484
411
  Style/TrailingCommaInArrayLiteral:
485
412
  Exclude:
486
413
  - 'lib/cucumber/cucumber_expressions/cucumber_expression_parser.rb'
487
- - 'spec/cucumber/cucumber_expressions/combinatorial_generated_expression_factory_test.rb'
414
+ - 'spec/cucumber/cucumber_expressions/combinatorial_generated_expression_factory_spec.rb'
488
415
 
489
416
  # Offense count: 1
490
417
  # This cop supports safe auto-correction (--auto-correct).
@@ -494,14 +421,6 @@ Style/TrailingCommaInHashLiteral:
494
421
  Exclude:
495
422
  - 'cucumber-cucumber-expressions.gemspec'
496
423
 
497
- # Offense count: 9
498
- # This cop supports safe auto-correction (--auto-correct).
499
- # Configuration parameters: ExactNameMatch, AllowPredicates, AllowDSLWriters, IgnoreClassMethods, AllowedMethods.
500
- # AllowedMethods: to_ary, to_a, to_c, to_enum, to_h, to_hash, to_i, to_int, to_io, to_open, to_path, to_proc, to_r, to_regexp, to_str, to_s, to_sym
501
- Style/TrivialAccessors:
502
- Exclude:
503
- - 'lib/cucumber/cucumber_expressions/ast.rb'
504
-
505
424
  # Offense count: 1
506
425
  # This cop supports safe auto-correction (--auto-correct).
507
426
  Style/WhileUntilDo:
data/VERSION CHANGED
@@ -1 +1 @@
1
- 17.0.1
1
+ 17.0.2
@@ -10,22 +10,27 @@ Gem::Specification.new do |s|
10
10
  s.description = 'Cucumber Expressions - a simpler alternative to Regular Expressions'
11
11
  s.summary = "cucumber-expressions-#{s.version}"
12
12
  s.email = 'cukes@googlegroups.com'
13
- s.homepage = 'https://github.com/cucumber/cucumber-expressions-ruby#readme'
13
+ s.homepage = 'https://github.com/cucumber/cucumber-expressions'
14
14
  s.platform = Gem::Platform::RUBY
15
15
  s.license = 'MIT'
16
16
  s.required_ruby_version = '>= 2.5'
17
17
 
18
18
  s.metadata = {
19
19
  'bug_tracker_uri' => 'https://github.com/cucumber/cucumber/issues',
20
- 'changelog_uri' => 'https://github.com/cucumber/common/blob/main/cucumber-expressions/CHANGELOG.md',
20
+ 'changelog_uri' => 'https://github.com/cucumber/common/blob/main/cucumber-expressions/CHANGELOG.md',
21
21
  'documentation_uri' => 'https://cucumber.io/docs/cucumber/cucumber-expressions/',
22
- 'mailing_list_uri' => 'https://groups.google.com/forum/#!forum/cukes',
23
- 'source_code_uri' => 'https://github.com/cucumber/common/blob/main/cucumber-expressions/ruby',
22
+ 'mailing_list_uri' => 'https://groups.google.com/forum/#!forum/cukes',
23
+ 'source_code_uri' => 'https://github.com/cucumber/common/blob/main/cucumber-expressions/ruby',
24
24
  }
25
25
 
26
+ s.add_runtime_dependency 'bigdecimal'
27
+
26
28
  s.add_development_dependency 'rake', '~> 13.0', '>= 13.0.6'
27
29
  s.add_development_dependency 'rspec', '~> 3.11', '>= 3.11.0'
28
30
  s.add_development_dependency 'rubocop', '~> 1.27.0'
31
+ s.add_development_dependency 'rubocop-performance', '~> 1.7.0'
32
+ s.add_development_dependency 'rubocop-rake', '~> 0.5.0'
33
+ s.add_development_dependency 'rubocop-rspec', '~> 2.0.0'
29
34
 
30
35
  s.files = `git ls-files`.split("\n").reject { |path| path =~ /\.gitignore$/ }
31
36
  s.rdoc_options = ['--charset=UTF-8']
@@ -30,7 +30,7 @@ module Cucumber
30
30
 
31
31
  (0...@parameter_type_combinations[depth].length).each do |i|
32
32
  # Avoid recursion if no elements can be added.
33
- return if generated_expressions.length >= MAX_EXPRESSIONS
33
+ break if generated_expressions.length >= MAX_EXPRESSIONS
34
34
 
35
35
  new_current_parameter_types = current_parameter_types.dup # clone
36
36
  new_current_parameter_types.push(@parameter_type_combinations[depth][i])
@@ -63,9 +63,9 @@ module Cucumber
63
63
  end
64
64
 
65
65
  def rewrite_optional(node)
66
- assert_no_parameters(node) { |astNode| raise ParameterIsNotAllowedInOptional.new(astNode, @expression) }
67
- assert_no_optionals(node) { |astNode| raise OptionalIsNotAllowedInOptional.new(astNode, @expression) }
68
- assert_not_empty(node) { |astNode| raise OptionalMayNotBeEmpty.new(astNode, @expression) }
66
+ assert_no_parameters(node) { |ast_node| raise ParameterIsNotAllowedInOptional.new(ast_node, @expression) }
67
+ assert_no_optionals(node) { |ast_node| raise OptionalIsNotAllowedInOptional.new(ast_node, @expression) }
68
+ assert_not_empty(node) { |ast_node| raise OptionalMayNotBeEmpty.new(ast_node, @expression) }
69
69
  regex = node.nodes.map { |n| rewrite_to_regex(n) }.join('')
70
70
  "(?:#{regex})?"
71
71
  end
@@ -75,14 +75,14 @@ module Cucumber
75
75
  node.nodes.each { |alternative|
76
76
  raise AlternativeMayNotBeEmpty.new(alternative, @expression) if alternative.nodes.length == 0
77
77
 
78
- assert_not_empty(alternative) { |astNode| raise AlternativeMayNotExclusivelyContainOptionals.new(astNode, @expression) }
78
+ assert_not_empty(alternative) { |ast_node| raise AlternativeMayNotExclusivelyContainOptionals.new(ast_node, @expression) }
79
79
  }
80
80
  regex = node.nodes.map { |n| rewrite_to_regex(n) }.join('|')
81
81
  "(?:#{regex})"
82
82
  end
83
83
 
84
84
  def rewrite_alternative(node)
85
- node.nodes.map { |lastNode| rewrite_to_regex(lastNode) }.join('')
85
+ node.nodes.map { |last_node| rewrite_to_regex(last_node) }.join('')
86
86
  end
87
87
 
88
88
  def rewrite_parameter(node)
@@ -103,17 +103,17 @@ module Cucumber
103
103
  end
104
104
 
105
105
  def assert_not_empty(node, &raise_error)
106
- text_nodes = node.nodes.select { |astNode| NodeType::TEXT == astNode.type }
106
+ text_nodes = node.nodes.select { |ast_node| NodeType::TEXT == ast_node.type }
107
107
  raise_error.call(node) if text_nodes.length == 0
108
108
  end
109
109
 
110
110
  def assert_no_parameters(node, &raise_error)
111
- nodes = node.nodes.select { |astNode| NodeType::PARAMETER == astNode.type }
111
+ nodes = node.nodes.select { |ast_node| NodeType::PARAMETER == ast_node.type }
112
112
  raise_error.call(nodes[0]) if nodes.length > 0
113
113
  end
114
114
 
115
115
  def assert_no_optionals(node, &raise_error)
116
- nodes = node.nodes.select { |astNode| NodeType::OPTIONAL == astNode.type }
116
+ nodes = node.nodes.select { |ast_node| NodeType::OPTIONAL == ast_node.type }
117
117
  raise_error.call(nodes[0]) if nodes.length > 0
118
118
  end
119
119
  end
@@ -76,7 +76,7 @@ module Cucumber
76
76
 
77
77
  consumed, ast = parse_tokens_until(expr, alternative_parsers, tokens, current, [TokenType::WHITE_SPACE, TokenType::END_OF_LINE, TokenType::BEGIN_PARAMETER])
78
78
  sub_current = current + consumed
79
- return [0, nil] unless ast.map { |astNode| astNode.type }.include? NodeType::ALTERNATIVE
79
+ return [0, nil] unless ast.map { |ast_node| ast_node.type }.include? NodeType::ALTERNATIVE
80
80
 
81
81
  start = tokens[current].start
82
82
  _end = tokens[sub_current].start
@@ -6,14 +6,14 @@ module Cucumber
6
6
  module CucumberExpressions
7
7
  class CucumberExpressionError < StandardError
8
8
  def build_message(index, expression, pointer, problem, solution)
9
- m = <<~EOF
9
+ m = <<~ERROR
10
10
  This Cucumber Expression has a problem at column #{index + 1}:
11
11
 
12
12
  #{expression}
13
13
  #{pointer}
14
14
  #{problem}.
15
15
  #{solution}
16
- EOF
16
+ ERROR
17
17
  m.strip
18
18
  end
19
19
 
@@ -41,7 +41,7 @@ module Cucumber
41
41
  expression,
42
42
  point_at_located(node),
43
43
  'An alternative may not exclusively contain optionals',
44
- "If you did not mean to use an optional you can use '\\(' to escape the the '('"
44
+ "If you did not mean to use an optional you can use '\\(' to escape the '('"
45
45
  )
46
46
  )
47
47
  end
@@ -55,7 +55,7 @@ module Cucumber
55
55
  expression,
56
56
  point_at_located(node),
57
57
  'Alternative may not be empty',
58
- "If you did not mean to use an alternative you can use '\\/' to escape the the '/'"
58
+ "If you did not mean to use an alternative you can use '\\/' to escape the '/'"
59
59
  )
60
60
  )
61
61
  end
@@ -83,7 +83,7 @@ module Cucumber
83
83
  expression,
84
84
  point_at_located(node),
85
85
  'An optional must contain some text',
86
- "If you did not mean to use an optional you can use '\\(' to escape the the '('"
86
+ "If you did not mean to use an optional you can use '\\(' to escape the '('"
87
87
  )
88
88
  )
89
89
  end
@@ -97,7 +97,7 @@ module Cucumber
97
97
  expression,
98
98
  point_at_located(node),
99
99
  'An optional may not contain a parameter type',
100
- "If you did not mean to use an parameter type you can use '\\{' to escape the the '{'"
100
+ "If you did not mean to use an parameter type you can use '\\{' to escape the '{'"
101
101
  )
102
102
  )
103
103
  end
@@ -111,7 +111,7 @@ module Cucumber
111
111
  expression,
112
112
  point_at_located(node),
113
113
  'An optional may not contain an other optional',
114
- "If you did not mean to use an optional type you can use '\\(' to escape the the '('. For more complicated expressions consider using a regular expression instead."
114
+ "If you did not mean to use an optional type you can use '\\(' to escape the '('. For more complicated expressions consider using a regular expression instead."
115
115
  )
116
116
  )
117
117
  end
@@ -126,7 +126,7 @@ module Cucumber
126
126
  expression,
127
127
  point_at(index),
128
128
  'The end of line can not be escaped',
129
- "You can use '\\\\' to escape the the '\\'"
129
+ "You can use '\\\\' to escape the '\\'"
130
130
  )
131
131
  )
132
132
  end
@@ -158,7 +158,7 @@ module Cucumber
158
158
  expression,
159
159
  point_at_located(current),
160
160
  'An alternation can not be used inside an optional',
161
- "You can use '\\/' to escape the the '/'"
161
+ "If you did not mean to use an alternation you can use '\\/' to escape the '/'. Otherwise rephrase your expression or consider using a regular expression instead."
162
162
  )
163
163
  )
164
164
  end
@@ -203,7 +203,7 @@ module Cucumber
203
203
 
204
204
  class AmbiguousParameterTypeError < CucumberExpressionError
205
205
  def initialize(parameter_type_regexp, expression_regexp, parameter_types, generated_expressions)
206
- super(<<~EOM)
206
+ super(<<~ERROR)
207
207
  Your Regular Expression /#{expression_regexp.source}/
208
208
  matches multiple parameter types with regexp /#{parameter_type_regexp}/:
209
209
  #{parameter_type_names(parameter_types)}
@@ -215,7 +215,7 @@ module Cucumber
215
215
 
216
216
  2) Make one of the parameter types preferential and continue to use a Regular Expression.
217
217
 
218
- EOM
218
+ ERROR
219
219
  end
220
220
 
221
221
  private
@@ -15,9 +15,7 @@ module Cucumber
15
15
  end
16
16
 
17
17
  def self.is_valid_parameter_type_name(type_name)
18
- unescaped_type_name = type_name.gsub(UNESCAPE_PATTERN) do
19
- $2
20
- end
18
+ unescaped_type_name = type_name.gsub(UNESCAPE_PATTERN) { Regexp.last_match(2) }
21
19
  !(ILLEGAL_PARAMETER_NAME_PATTERN =~ unescaped_type_name)
22
20
  end
23
21
 
@@ -11,8 +11,8 @@ module Cucumber
11
11
  end
12
12
 
13
13
  def advance_to(new_match_position)
14
- (new_match_position...@text.length).each do |advancedPos|
15
- matcher = self.class.new(parameter_type, @regexp, @text, advancedPos)
14
+ (new_match_position...@text.length).each do |advanced_position|
15
+ matcher = self.class.new(parameter_type, @regexp, @text, advanced_position)
16
16
  return matcher if matcher.find && matcher.full_word?
17
17
  end
18
18
 
@@ -10,7 +10,7 @@ module Cucumber
10
10
  it 'exposes parameter_type' do
11
11
  tree_regexp = TreeRegexp.new(/three (.*) mice/)
12
12
  parameter_type_registry = ParameterTypeRegistry.new
13
- arguments = Argument.build(tree_regexp, 'three blind mice', [parameter_type_registry.lookup_by_type_name('string')])
13
+ arguments = described_class.build(tree_regexp, 'three blind mice', [parameter_type_registry.lookup_by_type_name('string')])
14
14
  argument = arguments[0]
15
15
  expect(argument.parameter_type.name).to eq('string')
16
16
  end
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'cucumber/cucumber_expressions/parameter_type'
4
+ require 'cucumber/cucumber_expressions/combinatorial_generated_expression_factory'
5
+
6
+ describe Cucumber::CucumberExpressions::CombinatorialGeneratedExpressionFactory do
7
+ let(:klazz) { Class.new }
8
+ let(:color_parameter_type) do
9
+ Cucumber::CucumberExpressions::ParameterType.new('color', /red|blue|yellow/, klazz, ->(_) { klazz.new }, true, false)
10
+ end
11
+ let(:css_color_parameter_type) do
12
+ Cucumber::CucumberExpressions::ParameterType.new('csscolor', /red|blue|yellow/, klazz, ->(_) { klazz.new }, true, false)
13
+ end
14
+ let(:date_parameter_type) do
15
+ Cucumber::CucumberExpressions::ParameterType.new('date', /\d{4}-\d{2}-\d{2}/, klazz, ->(_) { klazz.new }, true, false)
16
+ end
17
+ let(:date_time_parameter_type) do
18
+ Cucumber::CucumberExpressions::ParameterType.new('datetime', /\d{4}-\d{2}-\d{2}/, klazz, ->(_) { klazz.new }, true, false)
19
+ end
20
+ let(:timestamp_parameter_type) do
21
+ Cucumber::CucumberExpressions::ParameterType.new('timestamp', /\d{4}-\d{2}-\d{2}/, klazz, ->(_) { klazz.new }, true, false)
22
+ end
23
+
24
+ it 'generates multiple expressions' do
25
+ parameter_type_combinations = [
26
+ [color_parameter_type, css_color_parameter_type],
27
+ [date_parameter_type, date_time_parameter_type, timestamp_parameter_type]
28
+ ]
29
+
30
+ factory = described_class.new('I bought a {%s} ball on {%s}', parameter_type_combinations)
31
+ expressions = factory.generate_expressions.map { |generated_expression| generated_expression.source }
32
+ expect(expressions).to eq([
33
+ 'I bought a {color} ball on {date}',
34
+ 'I bought a {color} ball on {datetime}',
35
+ 'I bought a {color} ball on {timestamp}',
36
+ 'I bought a {csscolor} ball on {date}',
37
+ 'I bought a {csscolor} ball on {datetime}',
38
+ 'I bought a {csscolor} ball on {timestamp}',
39
+ ])
40
+ end
41
+ end