cucumber-cucumber-expressions 8.3.1 → 19.0.0
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/LICENSE +2 -2
- data/lib/cucumber/cucumber_expressions/argument.rb +8 -4
- data/lib/cucumber/cucumber_expressions/ast.rb +166 -0
- data/lib/cucumber/cucumber_expressions/combinatorial_generated_expression_factory.rb +6 -13
- data/lib/cucumber/cucumber_expressions/cucumber_expression.rb +82 -80
- data/lib/cucumber/cucumber_expressions/cucumber_expression_generator.rb +14 -26
- data/lib/cucumber/cucumber_expressions/cucumber_expression_parser.rb +203 -0
- data/lib/cucumber/cucumber_expressions/cucumber_expression_tokenizer.rb +90 -0
- data/lib/cucumber/cucumber_expressions/errors.rb +205 -13
- data/lib/cucumber/cucumber_expressions/expression_factory.rb +24 -0
- data/lib/cucumber/cucumber_expressions/generated_expression.rb +2 -0
- data/lib/cucumber/cucumber_expressions/group.rb +7 -1
- data/lib/cucumber/cucumber_expressions/group_builder.rb +9 -2
- data/lib/cucumber/cucumber_expressions/parameter_type.rb +14 -21
- data/lib/cucumber/cucumber_expressions/parameter_type_matcher.rb +11 -9
- data/lib/cucumber/cucumber_expressions/parameter_type_registry.rb +28 -16
- data/lib/cucumber/cucumber_expressions/regular_expression.rb +3 -2
- data/lib/cucumber/cucumber_expressions/tree_regexp.rb +54 -46
- metadata +76 -77
- data/.github/ISSUE_TEMPLATE.md +0 -5
- data/.github/PULL_REQUEST_TEMPLATE.md +0 -5
- data/.rspec +0 -1
- data/.rsync +0 -4
- data/.subrepo +0 -1
- data/Gemfile +0 -3
- data/Makefile +0 -1
- data/README.md +0 -5
- data/Rakefile +0 -27
- data/cucumber-cucumber-expressions.gemspec +0 -33
- data/default.mk +0 -70
- data/examples.txt +0 -31
- data/scripts/update-gemspec +0 -32
- data/spec/capture_warnings.rb +0 -74
- data/spec/coverage.rb +0 -7
- data/spec/cucumber/cucumber_expressions/argument_spec.rb +0 -17
- data/spec/cucumber/cucumber_expressions/combinatorial_generated_expression_factory_test.rb +0 -43
- data/spec/cucumber/cucumber_expressions/cucumber_expression_generator_spec.rb +0 -231
- data/spec/cucumber/cucumber_expressions/cucumber_expression_regexp_spec.rb +0 -57
- data/spec/cucumber/cucumber_expressions/cucumber_expression_spec.rb +0 -212
- data/spec/cucumber/cucumber_expressions/custom_parameter_type_spec.rb +0 -202
- data/spec/cucumber/cucumber_expressions/expression_examples_spec.rb +0 -30
- data/spec/cucumber/cucumber_expressions/parameter_type_registry_spec.rb +0 -86
- data/spec/cucumber/cucumber_expressions/parameter_type_spec.rb +0 -15
- data/spec/cucumber/cucumber_expressions/regular_expression_spec.rb +0 -80
- data/spec/cucumber/cucumber_expressions/tree_regexp_spec.rb +0 -133
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
require 'cucumber/cucumber_expressions/tree_regexp'
|
|
2
|
-
|
|
3
|
-
module Cucumber
|
|
4
|
-
module CucumberExpressions
|
|
5
|
-
describe TreeRegexp do
|
|
6
|
-
it 'exposes group source' do
|
|
7
|
-
tr = TreeRegexp.new(/(a(?:b)?)(c)/)
|
|
8
|
-
expect(tr.group_builder.children.map{|gb| gb.source}).to eq(['a(?:b)?', 'c'])
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
it 'builds tree' do
|
|
12
|
-
tr = TreeRegexp.new(/(a(?:b)?)(c)/)
|
|
13
|
-
group = tr.match('ac')
|
|
14
|
-
expect(group.value).to eq('ac')
|
|
15
|
-
expect(group.children[0].value).to eq('a')
|
|
16
|
-
expect(group.children[0].children).to eq([])
|
|
17
|
-
expect(group.children[1].value).to eq('c')
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
it 'ignores `?:` as a non-capturing group' do
|
|
21
|
-
tr = TreeRegexp.new(/a(?:b)(c)/)
|
|
22
|
-
group = tr.match('abc')
|
|
23
|
-
expect(group.value).to eq('abc')
|
|
24
|
-
expect(group.children.length).to eq 1
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
it 'ignores `?!` as a non-capturing group' do
|
|
28
|
-
tr = TreeRegexp.new(/a(?!b)(.+)/)
|
|
29
|
-
group = tr.match('aBc')
|
|
30
|
-
expect(group.value).to eq('aBc')
|
|
31
|
-
expect(group.children.length).to eq 1
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
it 'ignores `?=` as a non-capturing group' do
|
|
35
|
-
tr = TreeRegexp.new(/a(?=b)(.+)$/)
|
|
36
|
-
group = tr.match('abc')
|
|
37
|
-
expect(group.value).to eq('abc')
|
|
38
|
-
expect(group.children[0].value).to eq('bc')
|
|
39
|
-
expect(group.children.length).to eq 1
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
it 'ignores `?<=` as a non-capturing group' do
|
|
43
|
-
tr = TreeRegexp.new(/a(.+)(?<=c)$/)
|
|
44
|
-
group = tr.match('abc')
|
|
45
|
-
expect(group.value).to eq('abc')
|
|
46
|
-
expect(group.children[0].value).to eq('bc')
|
|
47
|
-
expect(group.children.length).to eq 1
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
it 'ignores `?<!` as a non-capturing group' do
|
|
51
|
-
tr = TreeRegexp.new(/a(.+)(?<!b)$/)
|
|
52
|
-
group = tr.match('abc')
|
|
53
|
-
expect(group.value).to eq('abc')
|
|
54
|
-
expect(group.children[0].value).to eq('bc')
|
|
55
|
-
expect(group.children.length).to eq 1
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
it 'matches optional group' do
|
|
59
|
-
tr = TreeRegexp.new(/^Something( with an optional argument)?/)
|
|
60
|
-
group = tr.match('Something')
|
|
61
|
-
expect(group.children[0].value).to eq(nil)
|
|
62
|
-
end
|
|
63
|
-
|
|
64
|
-
it 'matches nested groups' do
|
|
65
|
-
tr = TreeRegexp.new(/^A (\d+) thick line from ((\d+),\s*(\d+),\s*(\d+)) to ((\d+),\s*(\d+),\s*(\d+))/)
|
|
66
|
-
group = tr.match('A 5 thick line from 10,20,30 to 40,50,60')
|
|
67
|
-
|
|
68
|
-
expect(group.children[0].value).to eq('5')
|
|
69
|
-
expect(group.children[1].value).to eq('10,20,30')
|
|
70
|
-
expect(group.children[1].children[0].value).to eq('10')
|
|
71
|
-
expect(group.children[1].children[1].value).to eq('20')
|
|
72
|
-
expect(group.children[1].children[2].value).to eq('30')
|
|
73
|
-
expect(group.children[2].value).to eq('40,50,60')
|
|
74
|
-
expect(group.children[2].children[0].value).to eq('40')
|
|
75
|
-
expect(group.children[2].children[1].value).to eq('50')
|
|
76
|
-
expect(group.children[2].children[2].value).to eq('60')
|
|
77
|
-
end
|
|
78
|
-
|
|
79
|
-
it 'detects multiple non capturing groups' do
|
|
80
|
-
tr = TreeRegexp.new(/(?:a)(:b)(\?c)(d)/)
|
|
81
|
-
group = tr.match("a:b?cd")
|
|
82
|
-
expect(group.children.length).to eq(3)
|
|
83
|
-
end
|
|
84
|
-
|
|
85
|
-
it 'works with escaped backslash' do
|
|
86
|
-
tr = TreeRegexp.new(/foo\\(bar|baz)/)
|
|
87
|
-
group = tr.match("foo\\bar")
|
|
88
|
-
expect(group.children.length).to eq(1)
|
|
89
|
-
end
|
|
90
|
-
|
|
91
|
-
it 'works with escaped slash' do
|
|
92
|
-
tr = TreeRegexp.new(/^I go to '\/(.+)'$/)
|
|
93
|
-
group = tr.match("I go to '/hello'")
|
|
94
|
-
expect(group.children.length).to eq(1)
|
|
95
|
-
end
|
|
96
|
-
|
|
97
|
-
it 'works with digit and word' do
|
|
98
|
-
tr = TreeRegexp.new(/^(\d) (\w+)$/)
|
|
99
|
-
group = tr.match("2 you")
|
|
100
|
-
expect(group.children.length).to eq(2)
|
|
101
|
-
end
|
|
102
|
-
|
|
103
|
-
it 'captures non capturing groups with capturing groups inside' do
|
|
104
|
-
tr = TreeRegexp.new(/the stdout(?: from "(.*?)")?/)
|
|
105
|
-
group = tr.match("the stdout")
|
|
106
|
-
expect(group.value).to eq("the stdout")
|
|
107
|
-
expect(group.children[0].value).to eq(nil)
|
|
108
|
-
expect(group.children.length).to eq(1)
|
|
109
|
-
end
|
|
110
|
-
|
|
111
|
-
it 'works with flags' do
|
|
112
|
-
tr = TreeRegexp.new(/HELLO/i)
|
|
113
|
-
group = tr.match("hello")
|
|
114
|
-
expect(group.value).to eq("hello")
|
|
115
|
-
end
|
|
116
|
-
|
|
117
|
-
it('does not consider parenthesis in character class as group') do
|
|
118
|
-
tr = TreeRegexp.new(/^drawings: ([A-Z_, ()]+)$/)
|
|
119
|
-
group = tr.match('drawings: ONE, TWO(ABC)')
|
|
120
|
-
expect(group.value).to eq('drawings: ONE, TWO(ABC)')
|
|
121
|
-
expect(group.children[0].value).to eq('ONE, TWO(ABC)')
|
|
122
|
-
expect(group.children.length).to eq(1)
|
|
123
|
-
end
|
|
124
|
-
|
|
125
|
-
it 'throws an error when there are named capture groups because they are buggy in Ruby' do
|
|
126
|
-
# https://github.com/cucumber/cucumber/issues/329
|
|
127
|
-
expect {
|
|
128
|
-
TreeRegexp.new(/^I am a person( named "(?<first_name>.+) (?<last_name>.+)")?$/)
|
|
129
|
-
}.to raise_error(/Named capture groups are not supported/)
|
|
130
|
-
end
|
|
131
|
-
end
|
|
132
|
-
end
|
|
133
|
-
end
|