cucumber-cucumber-expressions 17.0.1 → 17.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +13 -3
- data/.rubocop_todo.yml +60 -141
- data/VERSION +1 -1
- data/cucumber-cucumber-expressions.gemspec +9 -4
- data/lib/cucumber/cucumber_expressions/combinatorial_generated_expression_factory.rb +1 -1
- data/lib/cucumber/cucumber_expressions/cucumber_expression.rb +8 -8
- data/lib/cucumber/cucumber_expressions/cucumber_expression_parser.rb +1 -1
- data/lib/cucumber/cucumber_expressions/errors.rb +11 -11
- data/lib/cucumber/cucumber_expressions/parameter_type.rb +1 -3
- data/lib/cucumber/cucumber_expressions/parameter_type_matcher.rb +2 -2
- data/spec/cucumber/cucumber_expressions/argument_spec.rb +1 -1
- data/spec/cucumber/cucumber_expressions/combinatorial_generated_expression_factory_spec.rb +41 -0
- data/spec/cucumber/cucumber_expressions/cucumber_expression_generator_spec.rb +10 -10
- data/spec/cucumber/cucumber_expressions/cucumber_expression_parser_spec.rb +1 -1
- data/spec/cucumber/cucumber_expressions/cucumber_expression_spec.rb +8 -8
- data/spec/cucumber/cucumber_expressions/cucumber_expression_tokenizer_spec.rb +2 -2
- data/spec/cucumber/cucumber_expressions/cucumber_expression_transformation_spec.rb +2 -2
- data/spec/cucumber/cucumber_expressions/custom_parameter_type_spec.rb +7 -7
- data/spec/cucumber/cucumber_expressions/expression_factory_spec.rb +1 -1
- data/spec/cucumber/cucumber_expressions/parameter_type_registry_spec.rb +11 -11
- data/spec/cucumber/cucumber_expressions/parameter_type_spec.rb +1 -1
- data/spec/cucumber/cucumber_expressions/regular_expression_spec.rb +2 -2
- data/spec/cucumber/cucumber_expressions/tree_regexp_spec.rb +26 -27
- metadata +62 -6
- data/spec/cucumber/cucumber_expressions/combinatorial_generated_expression_factory_test.rb +0 -44
@@ -13,13 +13,13 @@ module Cucumber
|
|
13
13
|
|
14
14
|
before do
|
15
15
|
@parameter_type_registry = ParameterTypeRegistry.new
|
16
|
-
@generator =
|
16
|
+
@generator = described_class.new(@parameter_type_registry)
|
17
17
|
end
|
18
18
|
|
19
19
|
it 'documents expression generation' do
|
20
20
|
parameter_registry = ParameterTypeRegistry.new
|
21
21
|
### [generate-expression]
|
22
|
-
generator =
|
22
|
+
generator = described_class.new(parameter_registry)
|
23
23
|
undefined_step_text = 'I have 2 cucumbers and 1.5 tomato'
|
24
24
|
generated_expression = generator.generate_expressions(undefined_step_text)[0]
|
25
25
|
expect(generated_expression.source).to eq('I have {int} cucumbers and {float} tomato')
|
@@ -69,7 +69,7 @@ module Cucumber
|
|
69
69
|
'currency',
|
70
70
|
'[A-Z]{3}',
|
71
71
|
Currency,
|
72
|
-
->(s) { Currency.new(s)},
|
72
|
+
->(s) { Currency.new(s) },
|
73
73
|
true,
|
74
74
|
true
|
75
75
|
)
|
@@ -91,7 +91,7 @@ module Cucumber
|
|
91
91
|
'optional-flight',
|
92
92
|
/(1st flight)?/,
|
93
93
|
String,
|
94
|
-
->(s) { s},
|
94
|
+
->(s) { s },
|
95
95
|
true,
|
96
96
|
false
|
97
97
|
)
|
@@ -101,7 +101,7 @@ module Cucumber
|
|
101
101
|
'optional-hotel',
|
102
102
|
/(1 hotel)?/,
|
103
103
|
String,
|
104
|
-
->(s) { s},
|
104
|
+
->(s) { s },
|
105
105
|
true,
|
106
106
|
false
|
107
107
|
)
|
@@ -121,7 +121,7 @@ module Cucumber
|
|
121
121
|
"my-type-#{i}",
|
122
122
|
/([a-z] )*?[a-z]/,
|
123
123
|
String,
|
124
|
-
->(s) { s},
|
124
|
+
->(s) { s },
|
125
125
|
true,
|
126
126
|
false
|
127
127
|
)
|
@@ -139,7 +139,7 @@ module Cucumber
|
|
139
139
|
'zero-or-more',
|
140
140
|
/[a-z]*/,
|
141
141
|
String,
|
142
|
-
->(s) { s},
|
142
|
+
->(s) { s },
|
143
143
|
true,
|
144
144
|
false
|
145
145
|
)
|
@@ -149,7 +149,7 @@ module Cucumber
|
|
149
149
|
'exactly-one',
|
150
150
|
/[a-z]/,
|
151
151
|
String,
|
152
|
-
->(s) { s},
|
152
|
+
->(s) { s },
|
153
153
|
true,
|
154
154
|
false
|
155
155
|
)
|
@@ -168,7 +168,7 @@ module Cucumber
|
|
168
168
|
'direction',
|
169
169
|
/(up|down)/,
|
170
170
|
String,
|
171
|
-
->(s) { s},
|
171
|
+
->(s) { s },
|
172
172
|
true,
|
173
173
|
false
|
174
174
|
)
|
@@ -198,7 +198,7 @@ module Cucumber
|
|
198
198
|
'direction',
|
199
199
|
/(up|down)/,
|
200
200
|
String,
|
201
|
-
->(s) { s},
|
201
|
+
->(s) { s },
|
202
202
|
true,
|
203
203
|
false
|
204
204
|
)
|
@@ -10,7 +10,7 @@ module Cucumber
|
|
10
10
|
Dir['../testdata/cucumber-expression/parser/*.yaml'].each do |path|
|
11
11
|
expectation = YAML.load_file(path)
|
12
12
|
it "parses #{path}" do
|
13
|
-
parser =
|
13
|
+
parser = described_class.new
|
14
14
|
if expectation['exception']
|
15
15
|
expect { parser.parse(expectation['expression']) }.to raise_error(expectation['exception'])
|
16
16
|
else
|
@@ -14,11 +14,11 @@ module Cucumber
|
|
14
14
|
parameter_registry = ParameterTypeRegistry.new
|
15
15
|
if expectation['exception']
|
16
16
|
expect {
|
17
|
-
cucumber_expression =
|
17
|
+
cucumber_expression = described_class.new(expectation['expression'], parameter_registry)
|
18
18
|
cucumber_expression.match(expectation['text'])
|
19
19
|
}.to raise_error(expectation['exception'])
|
20
20
|
else
|
21
|
-
cucumber_expression =
|
21
|
+
cucumber_expression = described_class.new(expectation['expression'], parameter_registry)
|
22
22
|
matches = cucumber_expression.match(expectation['text'])
|
23
23
|
values = matches.nil? ? nil : matches.map do |arg|
|
24
24
|
value = arg.value(nil)
|
@@ -43,7 +43,7 @@ module Cucumber
|
|
43
43
|
|
44
44
|
### [capture-match-arguments]
|
45
45
|
expr = 'I have {int} cuke(s)'
|
46
|
-
expression =
|
46
|
+
expression = described_class.new(expr, parameter_registry)
|
47
47
|
args = expression.match('I have 7 cukes')
|
48
48
|
|
49
49
|
expect(args[0].value(nil)).to eq(7)
|
@@ -96,13 +96,13 @@ module Cucumber
|
|
96
96
|
it 'exposes source' do
|
97
97
|
expr = 'I have {int} cuke(s)'
|
98
98
|
|
99
|
-
expect(
|
99
|
+
expect(described_class.new(expr, ParameterTypeRegistry.new).source).to eq(expr)
|
100
100
|
end
|
101
101
|
|
102
102
|
it 'exposes source via #to_s' do
|
103
103
|
expr = 'I have {int} cuke(s)'
|
104
104
|
|
105
|
-
expect(
|
105
|
+
expect(described_class.new(expr, ParameterTypeRegistry.new).to_s).to eq(expr.inspect)
|
106
106
|
end
|
107
107
|
|
108
108
|
it 'unmatched optional groups have undefined values' do
|
@@ -117,7 +117,7 @@ module Cucumber
|
|
117
117
|
true
|
118
118
|
)
|
119
119
|
)
|
120
|
-
expression =
|
120
|
+
expression = described_class.new('{textAndOrNumber}', parameter_type_registry)
|
121
121
|
|
122
122
|
class World; end
|
123
123
|
|
@@ -139,7 +139,7 @@ module Cucumber
|
|
139
139
|
true
|
140
140
|
)
|
141
141
|
)
|
142
|
-
expression =
|
142
|
+
expression = described_class.new(
|
143
143
|
'I have a {widget}',
|
144
144
|
parameter_type_registry
|
145
145
|
)
|
@@ -158,7 +158,7 @@ module Cucumber
|
|
158
158
|
it 'reports undefined parameter type name' do
|
159
159
|
parameter_type_registry = ParameterTypeRegistry.new
|
160
160
|
|
161
|
-
|
161
|
+
described_class.new(
|
162
162
|
'I have {int} {widget}(s) in {word}',
|
163
163
|
parameter_type_registry
|
164
164
|
)
|
@@ -10,12 +10,12 @@ module Cucumber
|
|
10
10
|
Dir['../testdata/cucumber-expression/tokenizer/*.yaml'].each do |path|
|
11
11
|
expectation = YAML.load_file(path)
|
12
12
|
it "tokenizes #{path}" do
|
13
|
-
tokenizer =
|
13
|
+
tokenizer = described_class.new
|
14
14
|
if expectation['exception']
|
15
15
|
expect { tokenizer.tokenize(expectation['expression']) }.to raise_error(expectation['exception'])
|
16
16
|
else
|
17
17
|
tokens = tokenizer.tokenize(expectation['expression'])
|
18
|
-
token_hashes = tokens.map {|token| token.to_hash}
|
18
|
+
token_hashes = tokens.map { |token| token.to_hash }
|
19
19
|
expect(token_hashes).to eq(expectation['expected_tokens'])
|
20
20
|
end
|
21
21
|
end
|
@@ -13,11 +13,11 @@ module Cucumber
|
|
13
13
|
parameter_registry = ParameterTypeRegistry.new
|
14
14
|
if expectation['exception']
|
15
15
|
expect {
|
16
|
-
cucumber_expression =
|
16
|
+
cucumber_expression = described_class.new(expectation['expression'], parameter_registry)
|
17
17
|
cucumber_expression.match(expectation['text'])
|
18
18
|
}.to raise_error(expectation['exception'])
|
19
19
|
else
|
20
|
-
cucumber_expression =
|
20
|
+
cucumber_expression = described_class.new(expectation['expression'], parameter_registry)
|
21
21
|
matches = cucumber_expression.match(expectation['text'])
|
22
22
|
values = matches.nil? ? nil : matches.map { |arg| arg.value(nil) }
|
23
23
|
expect(values).to eq(expectation['expected_args'])
|
@@ -73,7 +73,7 @@ module Cucumber
|
|
73
73
|
|
74
74
|
describe CucumberExpression do
|
75
75
|
it 'matches parameters with custom parameter type' do
|
76
|
-
expression =
|
76
|
+
expression = described_class.new('I have a {color} ball', @parameter_type_registry)
|
77
77
|
transformed_argument_value = expression.match('I have a red ball')[0].value(nil)
|
78
78
|
|
79
79
|
expect(transformed_argument_value).to eq(Color.new('red'))
|
@@ -91,7 +91,7 @@ module Cucumber
|
|
91
91
|
)
|
92
92
|
)
|
93
93
|
|
94
|
-
expression =
|
94
|
+
expression = described_class.new('A {int} thick line from {coordinate} to {coordinate}', @parameter_type_registry)
|
95
95
|
args = expression.match('A 5 thick line from 10,20,30 to 40,50,60')
|
96
96
|
|
97
97
|
thick = args[0].value(nil)
|
@@ -116,7 +116,7 @@ module Cucumber
|
|
116
116
|
false
|
117
117
|
)
|
118
118
|
)
|
119
|
-
expression =
|
119
|
+
expression = described_class.new('I have a {color} ball', parameter_type_registry)
|
120
120
|
transformed_argument_value = expression.match('I have a dark red ball')[0].value(nil)
|
121
121
|
|
122
122
|
expect(transformed_argument_value).to eq(Color.new('dark red'))
|
@@ -133,7 +133,7 @@ module Cucumber
|
|
133
133
|
false
|
134
134
|
)
|
135
135
|
)
|
136
|
-
expression =
|
136
|
+
expression = described_class.new('I have a {throwing} parameter', @parameter_type_registry)
|
137
137
|
args = expression.match('I have a bad parameter')
|
138
138
|
|
139
139
|
expect { args[0].value(nil) }.to raise_error("Can't transform [bad]")
|
@@ -179,12 +179,12 @@ module Cucumber
|
|
179
179
|
false
|
180
180
|
)
|
181
181
|
)
|
182
|
-
css_color =
|
182
|
+
css_color = described_class.new('I have a {css-color} ball', @parameter_type_registry)
|
183
183
|
css_color_value = css_color.match('I have a blue ball')[0].value(nil)
|
184
184
|
|
185
185
|
expect(css_color_value).to eq(CssColor.new('blue'))
|
186
186
|
|
187
|
-
color =
|
187
|
+
color = described_class.new('I have a {color} ball', @parameter_type_registry)
|
188
188
|
color_value = color.match('I have a blue ball')[0].value(nil)
|
189
189
|
|
190
190
|
expect(color_value).to eq(Color.new('blue'))
|
@@ -205,7 +205,7 @@ module Cucumber
|
|
205
205
|
false
|
206
206
|
)
|
207
207
|
)
|
208
|
-
expression =
|
208
|
+
expression = described_class.new(/I have a (red|blue|yellow) ball/, parameter_type_registry)
|
209
209
|
value = expression.match('I have a red ball')[0].value(nil)
|
210
210
|
|
211
211
|
expect(value).to eq(Color.new('red'))
|
@@ -6,7 +6,7 @@ module Cucumber
|
|
6
6
|
module CucumberExpressions
|
7
7
|
describe ExpressionFactory do
|
8
8
|
before do
|
9
|
-
@expression_factory =
|
9
|
+
@expression_factory = described_class.new(ParameterTypeRegistry.new)
|
10
10
|
end
|
11
11
|
|
12
12
|
it 'creates a RegularExpression' do
|
@@ -14,24 +14,24 @@ module Cucumber
|
|
14
14
|
|
15
15
|
describe ParameterTypeRegistry do
|
16
16
|
before do
|
17
|
-
@registry =
|
17
|
+
@registry = described_class.new
|
18
18
|
end
|
19
19
|
|
20
20
|
it 'does not allow more than one prefer_for_regexp_match parameter type for each regexp' do
|
21
|
-
@registry.define_parameter_type(ParameterType.new('name', CAPITALISED_WORD, Name, ->(
|
22
|
-
@registry.define_parameter_type(ParameterType.new('person', CAPITALISED_WORD, Person, ->(
|
21
|
+
@registry.define_parameter_type(ParameterType.new('name', CAPITALISED_WORD, Name, ->(_) { Name.new }, true, true))
|
22
|
+
@registry.define_parameter_type(ParameterType.new('person', CAPITALISED_WORD, Person, ->(_) { Person.new }, true, false))
|
23
23
|
expect do
|
24
|
-
@registry.define_parameter_type(ParameterType.new('place', CAPITALISED_WORD, Place, ->(
|
24
|
+
@registry.define_parameter_type(ParameterType.new('place', CAPITALISED_WORD, Place, ->(_) { Place.new }, true, true))
|
25
25
|
end.to raise_error(
|
26
26
|
CucumberExpressionError,
|
27
|
-
'There can only be one preferential parameter type per regexp. The regexp /[A-Z]+\\w+/ is used for two
|
27
|
+
'There can only be one preferential parameter type per regexp. The regexp /[A-Z]+\\w+/ is used for two: {name} and {place}'
|
28
28
|
)
|
29
29
|
end
|
30
30
|
|
31
31
|
it 'looks up prefer_for_regexp_match parameter type by regexp' do
|
32
|
-
name = ParameterType.new('name', CAPITALISED_WORD, Name, ->(
|
33
|
-
person = ParameterType.new('person', CAPITALISED_WORD, Person, ->(
|
34
|
-
place = ParameterType.new('place', CAPITALISED_WORD, Place, ->(
|
32
|
+
name = ParameterType.new('name', CAPITALISED_WORD, Name, ->(_) { Name.new }, true, false)
|
33
|
+
person = ParameterType.new('person', CAPITALISED_WORD, Person, ->(_) { Person.new }, true, true)
|
34
|
+
place = ParameterType.new('place', CAPITALISED_WORD, Place, ->(_) { Place.new }, true, false)
|
35
35
|
|
36
36
|
@registry.define_parameter_type(name)
|
37
37
|
@registry.define_parameter_type(person)
|
@@ -41,9 +41,9 @@ module Cucumber
|
|
41
41
|
end
|
42
42
|
|
43
43
|
it 'throws ambiguous exception when no parameter types are prefer_for_regexp_match' do
|
44
|
-
name = ParameterType.new('name', CAPITALISED_WORD, Name, ->(
|
45
|
-
person = ParameterType.new('person', CAPITALISED_WORD, Person, ->(
|
46
|
-
place = ParameterType.new('place', CAPITALISED_WORD, Place, ->(
|
44
|
+
name = ParameterType.new('name', CAPITALISED_WORD, Name, ->(_) { Name.new }, true, false)
|
45
|
+
person = ParameterType.new('person', CAPITALISED_WORD, Person, ->(_) { Person.new }, true, false)
|
46
|
+
place = ParameterType.new('place', CAPITALISED_WORD, Place, ->(_) { Place.new }, true, false)
|
47
47
|
|
48
48
|
@registry.define_parameter_type(name)
|
49
49
|
@registry.define_parameter_type(person)
|
@@ -7,7 +7,7 @@ module Cucumber
|
|
7
7
|
describe ParameterType do
|
8
8
|
it 'does not allow ignore flag on regexp' do
|
9
9
|
expect do
|
10
|
-
|
10
|
+
described_class.new('case-insensitive', /[a-z]+/i, String, ->(s) { s }, true, true)
|
11
11
|
end.to raise_error(
|
12
12
|
CucumberExpressionError,
|
13
13
|
"ParameterType Regexps can't use option Regexp::IGNORECASE"
|
@@ -12,7 +12,7 @@ module Cucumber
|
|
12
12
|
|
13
13
|
it "matches #{path}" do
|
14
14
|
parameter_registry = ParameterTypeRegistry.new
|
15
|
-
expression =
|
15
|
+
expression = described_class.new(Regexp.new(expectation['expression']), parameter_registry)
|
16
16
|
matches = expression.match(expectation['text'])
|
17
17
|
values = matches.map { |arg| arg.value(nil) }
|
18
18
|
|
@@ -75,7 +75,7 @@ module Cucumber
|
|
75
75
|
|
76
76
|
it 'exposes source and regexp' do
|
77
77
|
regexp = /I have (\d+) cukes? in my (\+) now/
|
78
|
-
expression =
|
78
|
+
expression = described_class.new(regexp, ParameterTypeRegistry.new)
|
79
79
|
|
80
80
|
expect(expression.regexp).to eq(regexp)
|
81
81
|
expect(expression.source).to eq(regexp.source)
|
@@ -6,12 +6,12 @@ module Cucumber
|
|
6
6
|
module CucumberExpressions
|
7
7
|
describe TreeRegexp do
|
8
8
|
it 'exposes the group source' do
|
9
|
-
tr =
|
9
|
+
tr = described_class.new(/(a(?:b)?)(c)/)
|
10
10
|
expect(tr.group_builder.children.map { |gb| gb.source }).to eq(['a(?:b)?', 'c'])
|
11
11
|
end
|
12
12
|
|
13
13
|
it 'builds a tree' do
|
14
|
-
tr =
|
14
|
+
tr = described_class.new(/(a(?:b)?)(c)/)
|
15
15
|
group = tr.match('ac')
|
16
16
|
expect(group.value).to eq('ac')
|
17
17
|
expect(group.children[0].value).to eq('a')
|
@@ -20,7 +20,7 @@ module Cucumber
|
|
20
20
|
end
|
21
21
|
|
22
22
|
it 'ignores `?:` as a non-capturing group' do
|
23
|
-
tr =
|
23
|
+
tr = described_class.new(/a(?:b)(c)/)
|
24
24
|
group = tr.match('abc')
|
25
25
|
expect(group.value).to eq('abc')
|
26
26
|
expect(group.children.length).to eq 1
|
@@ -28,14 +28,14 @@ module Cucumber
|
|
28
28
|
end
|
29
29
|
|
30
30
|
it 'ignores `?!` as a non-capturing group' do
|
31
|
-
tr =
|
31
|
+
tr = described_class.new(/a(?!b)(.+)/)
|
32
32
|
group = tr.match('aBc')
|
33
33
|
expect(group.value).to eq('aBc')
|
34
34
|
expect(group.children.length).to eq 1
|
35
35
|
end
|
36
36
|
|
37
37
|
it 'ignores `?=` as a non-capturing group' do
|
38
|
-
tr =
|
38
|
+
tr = described_class.new(/a(?=b)(.+)$/)
|
39
39
|
group = tr.match('abc')
|
40
40
|
expect(group.value).to eq('abc')
|
41
41
|
expect(group.children[0].value).to eq('bc')
|
@@ -43,7 +43,7 @@ module Cucumber
|
|
43
43
|
end
|
44
44
|
|
45
45
|
it 'ignores `?<=` as a non-capturing group' do
|
46
|
-
tr =
|
46
|
+
tr = described_class.new(/a(.+)(?<=c)$/)
|
47
47
|
group = tr.match('abc')
|
48
48
|
expect(group.value).to eq('abc')
|
49
49
|
expect(group.children[0].value).to eq('bc')
|
@@ -51,7 +51,7 @@ module Cucumber
|
|
51
51
|
end
|
52
52
|
|
53
53
|
it 'ignores `?<!` as a non-capturing group' do
|
54
|
-
tr =
|
54
|
+
tr = described_class.new(/a(.+)(?<!b)$/)
|
55
55
|
group = tr.match('abc')
|
56
56
|
expect(group.value).to eq('abc')
|
57
57
|
expect(group.children[0].value).to eq('bc')
|
@@ -59,7 +59,7 @@ module Cucumber
|
|
59
59
|
end
|
60
60
|
|
61
61
|
it 'ignores `?<!` as a non-capturing group' do
|
62
|
-
tr =
|
62
|
+
tr = described_class.new(/a(.+)(?<!b)$/)
|
63
63
|
group = tr.match('abc')
|
64
64
|
expect(group.value).to eq('abc')
|
65
65
|
expect(group.children[0].value).to eq('bc')
|
@@ -67,7 +67,7 @@ module Cucumber
|
|
67
67
|
end
|
68
68
|
|
69
69
|
it 'ignores `?>` as a non-capturing group' do
|
70
|
-
tr =
|
70
|
+
tr = described_class.new(/a(?>b)c/)
|
71
71
|
group = tr.match('abc')
|
72
72
|
expect(group.value).to eq('abc')
|
73
73
|
expect(group.children.length).to eq 0
|
@@ -75,19 +75,18 @@ module Cucumber
|
|
75
75
|
|
76
76
|
it 'throws an error when there are named capture groups because they are buggy in Ruby' do
|
77
77
|
# https://github.com/cucumber/cucumber/issues/329
|
78
|
-
expect {
|
79
|
-
|
80
|
-
}.to raise_error(/Named capture groups are not supported/)
|
78
|
+
expect { described_class.new(/^I am a person( named "(?<first_name>.+) (?<last_name>.+)")?$/) }
|
79
|
+
.to raise_error(/Named capture groups are not supported/)
|
81
80
|
end
|
82
81
|
|
83
82
|
it 'matches an optional group' do
|
84
|
-
tr =
|
83
|
+
tr = described_class.new(/^Something( with an optional argument)?/)
|
85
84
|
group = tr.match('Something')
|
86
|
-
expect(group.children[0].value).to
|
85
|
+
expect(group.children[0].value).to be_nil
|
87
86
|
end
|
88
87
|
|
89
88
|
it 'matches nested groups' do
|
90
|
-
tr =
|
89
|
+
tr = described_class.new(/^A (\d+) thick line from ((\d+),\s*(\d+),\s*(\d+)) to ((\d+),\s*(\d+),\s*(\d+))/)
|
91
90
|
group = tr.match('A 5 thick line from 10,20,30 to 40,50,60')
|
92
91
|
|
93
92
|
expect(group.children[0].value).to eq('5')
|
@@ -102,31 +101,31 @@ module Cucumber
|
|
102
101
|
end
|
103
102
|
|
104
103
|
it 'detects multiple non-capturing groups' do
|
105
|
-
tr =
|
104
|
+
tr = described_class.new(/(?:a)(:b)(\?c)(d)/)
|
106
105
|
group = tr.match('a:b?cd')
|
107
106
|
expect(group.children.length).to eq(3)
|
108
107
|
end
|
109
108
|
|
110
109
|
it 'works with escaped backslashes' do
|
111
|
-
tr =
|
110
|
+
tr = described_class.new(/foo\\(bar|baz)/)
|
112
111
|
group = tr.match('foo\\bar')
|
113
112
|
expect(group.children.length).to eq(1)
|
114
113
|
end
|
115
114
|
|
116
115
|
it 'works with escaped slashes' do
|
117
|
-
tr =
|
116
|
+
tr = described_class.new(/^I go to '\/(.+)'$/)
|
118
117
|
group = tr.match("I go to '/hello'")
|
119
118
|
expect(group.children.length).to eq(1)
|
120
119
|
end
|
121
120
|
|
122
121
|
it 'works with digit and word regexp metacharacters' do
|
123
|
-
tr =
|
122
|
+
tr = described_class.new(/^(\d) (\w+)$/)
|
124
123
|
group = tr.match('2 you')
|
125
124
|
expect(group.children.length).to eq(2)
|
126
125
|
end
|
127
126
|
|
128
127
|
it 'captures non-capturing groups with capturing groups inside' do
|
129
|
-
tr =
|
128
|
+
tr = described_class.new(/the stdout(?: from "(.*?)")?/)
|
130
129
|
group = tr.match('the stdout')
|
131
130
|
expect(group.value).to eq('the stdout')
|
132
131
|
expect(group.children[0].value).to eq(nil)
|
@@ -134,13 +133,13 @@ module Cucumber
|
|
134
133
|
end
|
135
134
|
|
136
135
|
it 'works with flags' do
|
137
|
-
tr =
|
136
|
+
tr = described_class.new(/HELLO/i)
|
138
137
|
group = tr.match('hello')
|
139
138
|
expect(group.value).to eq('hello')
|
140
139
|
end
|
141
140
|
|
142
141
|
it('does not consider parentheses in regexp character classes as a group') do
|
143
|
-
tr =
|
142
|
+
tr = described_class.new(/^drawings: ([A-Z_, ()]+)$/)
|
144
143
|
group = tr.match('drawings: ONE, TWO(ABC)')
|
145
144
|
expect(group.value).to eq('drawings: ONE, TWO(ABC)')
|
146
145
|
expect(group.children[0].value).to eq('ONE, TWO(ABC)')
|
@@ -148,21 +147,21 @@ module Cucumber
|
|
148
147
|
end
|
149
148
|
|
150
149
|
it 'works with inline flags' do
|
151
|
-
tr =
|
150
|
+
tr = described_class.new(/(?i)HELLO/)
|
152
151
|
group = tr.match('hello')
|
153
152
|
expect(group.value).to eq('hello')
|
154
153
|
expect(group.children.length).to eq 0
|
155
154
|
end
|
156
155
|
|
157
156
|
it 'works with non-capturing inline flags' do
|
158
|
-
tr =
|
157
|
+
tr = described_class.new(/(?i:HELLO)/)
|
159
158
|
group = tr.match('hello')
|
160
159
|
expect(group.value).to eq('hello')
|
161
160
|
expect(group.children.length).to eq 0
|
162
161
|
end
|
163
162
|
|
164
163
|
it 'works with empty capturing groups' do
|
165
|
-
tr =
|
164
|
+
tr = described_class.new(/()/)
|
166
165
|
group = tr.match('')
|
167
166
|
expect(group.value).to eq('')
|
168
167
|
expect(group.children[0].value).to eq('')
|
@@ -170,14 +169,14 @@ module Cucumber
|
|
170
169
|
end
|
171
170
|
|
172
171
|
it 'works with empty non-capturing groups' do
|
173
|
-
tr =
|
172
|
+
tr = described_class.new(/(?:)/)
|
174
173
|
group = tr.match('')
|
175
174
|
expect(group.value).to eq('')
|
176
175
|
expect(group.children.length).to eq 0
|
177
176
|
end
|
178
177
|
|
179
178
|
it 'works with empty non-look ahead groups' do
|
180
|
-
tr =
|
179
|
+
tr = described_class.new(/(?<=)/)
|
181
180
|
group = tr.match('')
|
182
181
|
expect(group.value).to eq('')
|
183
182
|
expect(group.children.length).to eq 0
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cucumber-cucumber-expressions
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 17.0.
|
4
|
+
version: 17.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aslak Hellesøy
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-02-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bigdecimal
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: rake
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -64,6 +78,48 @@ dependencies:
|
|
64
78
|
- - "~>"
|
65
79
|
- !ruby/object:Gem::Version
|
66
80
|
version: 1.27.0
|
81
|
+
- !ruby/object:Gem::Dependency
|
82
|
+
name: rubocop-performance
|
83
|
+
requirement: !ruby/object:Gem::Requirement
|
84
|
+
requirements:
|
85
|
+
- - "~>"
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: 1.7.0
|
88
|
+
type: :development
|
89
|
+
prerelease: false
|
90
|
+
version_requirements: !ruby/object:Gem::Requirement
|
91
|
+
requirements:
|
92
|
+
- - "~>"
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: 1.7.0
|
95
|
+
- !ruby/object:Gem::Dependency
|
96
|
+
name: rubocop-rake
|
97
|
+
requirement: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - "~>"
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: 0.5.0
|
102
|
+
type: :development
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
requirements:
|
106
|
+
- - "~>"
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: 0.5.0
|
109
|
+
- !ruby/object:Gem::Dependency
|
110
|
+
name: rubocop-rspec
|
111
|
+
requirement: !ruby/object:Gem::Requirement
|
112
|
+
requirements:
|
113
|
+
- - "~>"
|
114
|
+
- !ruby/object:Gem::Version
|
115
|
+
version: 2.0.0
|
116
|
+
type: :development
|
117
|
+
prerelease: false
|
118
|
+
version_requirements: !ruby/object:Gem::Requirement
|
119
|
+
requirements:
|
120
|
+
- - "~>"
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: 2.0.0
|
67
123
|
description: Cucumber Expressions - a simpler alternative to Regular Expressions
|
68
124
|
email: cukes@googlegroups.com
|
69
125
|
executables: []
|
@@ -94,7 +150,7 @@ files:
|
|
94
150
|
- lib/cucumber/cucumber_expressions/regular_expression.rb
|
95
151
|
- lib/cucumber/cucumber_expressions/tree_regexp.rb
|
96
152
|
- spec/cucumber/cucumber_expressions/argument_spec.rb
|
97
|
-
- spec/cucumber/cucumber_expressions/
|
153
|
+
- spec/cucumber/cucumber_expressions/combinatorial_generated_expression_factory_spec.rb
|
98
154
|
- spec/cucumber/cucumber_expressions/cucumber_expression_generator_spec.rb
|
99
155
|
- spec/cucumber/cucumber_expressions/cucumber_expression_parser_spec.rb
|
100
156
|
- spec/cucumber/cucumber_expressions/cucumber_expression_spec.rb
|
@@ -106,7 +162,7 @@ files:
|
|
106
162
|
- spec/cucumber/cucumber_expressions/parameter_type_spec.rb
|
107
163
|
- spec/cucumber/cucumber_expressions/regular_expression_spec.rb
|
108
164
|
- spec/cucumber/cucumber_expressions/tree_regexp_spec.rb
|
109
|
-
homepage: https://github.com/cucumber/cucumber-expressions
|
165
|
+
homepage: https://github.com/cucumber/cucumber-expressions
|
110
166
|
licenses:
|
111
167
|
- MIT
|
112
168
|
metadata:
|
@@ -131,8 +187,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
131
187
|
- !ruby/object:Gem::Version
|
132
188
|
version: '0'
|
133
189
|
requirements: []
|
134
|
-
rubygems_version: 3.4.
|
190
|
+
rubygems_version: 3.4.19
|
135
191
|
signing_key:
|
136
192
|
specification_version: 4
|
137
|
-
summary: cucumber-expressions-17.0.
|
193
|
+
summary: cucumber-expressions-17.0.2
|
138
194
|
test_files: []
|