cucumber-gherkin 15.0.2 → 20.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -3
- data/bin/gherkin +6 -28
- data/lib/gherkin.rb +2 -2
- data/lib/gherkin/ast_builder.rb +29 -28
- data/lib/gherkin/gherkin-languages.json +58 -11
- data/lib/gherkin/gherkin_line.rb +1 -1
- data/lib/gherkin/parser.rb +913 -445
- data/lib/gherkin/pickles/compiler.rb +17 -15
- data/lib/gherkin/query.rb +5 -2
- data/lib/gherkin/stream/parser_message_stream.rb +5 -2
- data/lib/gherkin/token_scanner.rb +1 -1
- data/spec/gherkin/gherkin_line_spec.rb +11 -1
- data/spec/gherkin/query_spec.rb +24 -23
- data/spec/gherkin/stream/parser_message_stream_spec.rb +3 -3
- metadata +19 -22
- data/lib/gherkin/stream/subprocess_message_stream.rb +0 -26
- data/spec/gherkin/stream/subprocess_message_stream_spec.rb +0 -18
@@ -37,7 +37,9 @@ module Gherkin
|
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
40
|
-
def compile_rule(pickles, language,
|
40
|
+
def compile_rule(pickles, language, feature_tags, feature_background_steps, rule, source)
|
41
|
+
tags = [].concat(feature_tags).concat(rule.tags)
|
42
|
+
|
41
43
|
rule_background_steps = feature_background_steps.dup
|
42
44
|
rule.children.each do |child|
|
43
45
|
if child.background
|
@@ -53,10 +55,10 @@ module Gherkin
|
|
53
55
|
end
|
54
56
|
end
|
55
57
|
|
56
|
-
def compile_scenario(
|
58
|
+
def compile_scenario(inherited_tags, background_steps, scenario, language, pickles, source)
|
57
59
|
steps = scenario.steps.empty? ? [] : [].concat(pickle_steps(background_steps))
|
58
60
|
|
59
|
-
tags = [].concat(
|
61
|
+
tags = [].concat(inherited_tags).concat(scenario.tags)
|
60
62
|
|
61
63
|
scenario.steps.each do |step|
|
62
64
|
steps.push(pickle_step(step))
|
@@ -74,17 +76,17 @@ module Gherkin
|
|
74
76
|
pickles.push(pickle)
|
75
77
|
end
|
76
78
|
|
77
|
-
def compile_scenario_outline(
|
79
|
+
def compile_scenario_outline(inherited_tags, background_steps, scenario, language, pickles, source)
|
78
80
|
scenario.examples.reject { |examples| examples.table_header.nil? }.each do |examples|
|
79
81
|
variable_cells = examples.table_header.cells
|
80
82
|
examples.table_body.each do |values_row|
|
81
83
|
value_cells = values_row.cells
|
82
84
|
steps = scenario.steps.empty? ? [] : [].concat(pickle_steps(background_steps))
|
83
|
-
tags = [].concat(
|
85
|
+
tags = [].concat(inherited_tags).concat(scenario.tags).concat(examples.tags)
|
84
86
|
|
85
|
-
scenario.steps.each do |
|
86
|
-
step_props = pickle_step_props(
|
87
|
-
steps.push(Cucumber::Messages::
|
87
|
+
scenario.steps.each do |scenario_step|
|
88
|
+
step_props = pickle_step_props(scenario_step, variable_cells, values_row)
|
89
|
+
steps.push(Cucumber::Messages::PickleStep.new(**step_props))
|
88
90
|
end
|
89
91
|
|
90
92
|
pickle = Cucumber::Messages::Pickle.new(
|
@@ -97,7 +99,7 @@ module Gherkin
|
|
97
99
|
ast_node_ids: [
|
98
100
|
scenario.id,
|
99
101
|
values_row.id
|
100
|
-
]
|
102
|
+
]
|
101
103
|
)
|
102
104
|
pickles.push(pickle)
|
103
105
|
|
@@ -120,7 +122,7 @@ module Gherkin
|
|
120
122
|
end
|
121
123
|
|
122
124
|
def pickle_step(step)
|
123
|
-
Cucumber::Messages::
|
125
|
+
Cucumber::Messages::PickleStep.new(**pickle_step_props(step, [], nil))
|
124
126
|
end
|
125
127
|
|
126
128
|
def pickle_step_props(step, variable_cells, values_row)
|
@@ -150,11 +152,11 @@ module Gherkin
|
|
150
152
|
end
|
151
153
|
|
152
154
|
def pickle_data_table(data_table, variable_cells, value_cells)
|
153
|
-
Cucumber::Messages::
|
155
|
+
Cucumber::Messages::PickleTable.new(
|
154
156
|
rows: data_table.rows.map do |row|
|
155
|
-
Cucumber::Messages::
|
157
|
+
Cucumber::Messages::PickleTableRow.new(
|
156
158
|
cells: row.cells.map do |cell|
|
157
|
-
Cucumber::Messages::
|
159
|
+
Cucumber::Messages::PickleTableCell.new(
|
158
160
|
value: interpolate(cell.value, variable_cells, value_cells)
|
159
161
|
)
|
160
162
|
end
|
@@ -170,7 +172,7 @@ module Gherkin
|
|
170
172
|
if doc_string.media_type
|
171
173
|
props[:media_type] = interpolate(doc_string.media_type, variable_cells, value_cells)
|
172
174
|
end
|
173
|
-
Cucumber::Messages::
|
175
|
+
Cucumber::Messages::PickleDocString.new(**props)
|
174
176
|
end
|
175
177
|
|
176
178
|
def pickle_tags(tags)
|
@@ -178,7 +180,7 @@ module Gherkin
|
|
178
180
|
end
|
179
181
|
|
180
182
|
def pickle_tag(tag)
|
181
|
-
Cucumber::Messages::
|
183
|
+
Cucumber::Messages::PickleTag.new(
|
182
184
|
name: tag.name,
|
183
185
|
ast_node_id: tag.id
|
184
186
|
)
|
data/lib/gherkin/query.rb
CHANGED
@@ -27,6 +27,9 @@ module Gherkin
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def update_rule(rule)
|
30
|
+
return if rule.nil?
|
31
|
+
store_nodes_location(rule.tags)
|
32
|
+
|
30
33
|
rule.children.each do |child|
|
31
34
|
update_background(child.background) if child.background
|
32
35
|
update_scenario(child.scenario) if child.scenario
|
@@ -42,8 +45,8 @@ module Gherkin
|
|
42
45
|
store_nodes_location(scenario.tags)
|
43
46
|
update_steps(scenario.steps)
|
44
47
|
scenario.examples.each do |examples|
|
45
|
-
store_nodes_location(examples.tags)
|
46
|
-
store_nodes_location(examples.table_body)
|
48
|
+
store_nodes_location(examples.tags || [])
|
49
|
+
store_nodes_location(examples.table_body || [])
|
47
50
|
end
|
48
51
|
end
|
49
52
|
|
@@ -88,8 +88,11 @@ module Gherkin
|
|
88
88
|
else
|
89
89
|
gd = @parser.parse(source.data)
|
90
90
|
end
|
91
|
-
|
92
|
-
|
91
|
+
Cucumber::Messages::GherkinDocument.new(
|
92
|
+
uri: source.uri,
|
93
|
+
feature: gd.feature,
|
94
|
+
comments: gd.comments
|
95
|
+
)
|
93
96
|
end
|
94
97
|
end
|
95
98
|
end
|
@@ -25,7 +25,7 @@ module Gherkin
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def read
|
28
|
-
location = {line: @line_number += 1
|
28
|
+
location = {line: @line_number += 1}
|
29
29
|
if @io.nil? || line = @io.gets
|
30
30
|
gherkin_line = line ? GherkinLine.new(line, location[:line]) : nil
|
31
31
|
Token.new(gherkin_line, location)
|
@@ -2,7 +2,17 @@ require 'rspec'
|
|
2
2
|
require 'gherkin/gherkin_line'
|
3
3
|
|
4
4
|
describe Gherkin::GherkinLine do
|
5
|
-
context '#
|
5
|
+
context '#tags' do
|
6
|
+
def tags(line)
|
7
|
+
Gherkin::GherkinLine.new(line, 12).tags.map(&:text)
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'allows any non-space characters in a tag' do
|
11
|
+
expect(tags(" @foo:bar @zap🥒yo")).to eq(['@foo:bar', '@zap🥒yo'])
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
context '#table_cells' do
|
6
16
|
def cells_text(line)
|
7
17
|
Gherkin::GherkinLine.new(line, 12).table_cells.map(&:text)
|
8
18
|
end
|
data/spec/gherkin/query_spec.rb
CHANGED
@@ -3,7 +3,7 @@ require 'gherkin'
|
|
3
3
|
require 'gherkin/query'
|
4
4
|
|
5
5
|
describe Gherkin::Query do
|
6
|
-
let(:subject) { Gherkin::Query.new
|
6
|
+
let(:subject) { Gherkin::Query.new }
|
7
7
|
|
8
8
|
def filter_messages_by_attribute(messages, attribute)
|
9
9
|
messages.map do |message|
|
@@ -18,7 +18,7 @@ describe Gherkin::Query do
|
|
18
18
|
|
19
19
|
let(:gherkin_document) { find_message_by_attribute(messages, :gherkin_document) }
|
20
20
|
|
21
|
-
let(:messages)
|
21
|
+
let(:messages) do
|
22
22
|
Gherkin.from_source(
|
23
23
|
"some/path",
|
24
24
|
feature_content,
|
@@ -26,9 +26,9 @@ describe Gherkin::Query do
|
|
26
26
|
include_gherkin_document: true
|
27
27
|
}
|
28
28
|
).to_a
|
29
|
-
|
29
|
+
end
|
30
30
|
|
31
|
-
let(:feature_content)
|
31
|
+
let(:feature_content) do
|
32
32
|
"""
|
33
33
|
@feature-tag
|
34
34
|
Feature: my feature
|
@@ -43,12 +43,12 @@ describe Gherkin::Query do
|
|
43
43
|
Scenario Outline: with examples
|
44
44
|
Given a <Status> step
|
45
45
|
|
46
|
-
@
|
46
|
+
@examples-tag
|
47
47
|
Examples:
|
48
48
|
| Status |
|
49
49
|
| passed |
|
50
50
|
|
51
|
-
|
51
|
+
@rule-tag
|
52
52
|
Rule: this is a rule
|
53
53
|
Background:
|
54
54
|
Given the passed step in the rule background
|
@@ -56,31 +56,28 @@ describe Gherkin::Query do
|
|
56
56
|
@ruled-scenario-tag
|
57
57
|
Scenario: a ruled scenario
|
58
58
|
Given a step in the ruled scenario
|
59
|
-
|
60
|
-
|
59
|
+
"""
|
60
|
+
end
|
61
61
|
|
62
|
-
|
62
|
+
describe '#update' do
|
63
63
|
context 'when the feature file is empty' do
|
64
64
|
let(:feature_content) { '' }
|
65
65
|
|
66
66
|
it 'does not fail' do
|
67
|
-
expect
|
68
|
-
messages.each { |message|
|
69
|
-
|
70
|
-
}
|
71
|
-
}.not_to raise_exception
|
67
|
+
expect do
|
68
|
+
messages.each { |message| subject.update(message) }
|
69
|
+
end.not_to raise_exception
|
72
70
|
end
|
73
71
|
end
|
74
72
|
end
|
75
73
|
|
76
|
-
|
74
|
+
describe '#location' do
|
77
75
|
before do
|
78
|
-
messages.each { |message|
|
79
|
-
subject.update(message)
|
80
|
-
}
|
76
|
+
messages.each { |message| subject.update(message) }
|
81
77
|
end
|
82
78
|
|
83
79
|
let(:background) { find_message_by_attribute(gherkin_document.feature.children, :background) }
|
80
|
+
let(:rule) { find_message_by_attribute(gherkin_document.feature.children, :rule) }
|
84
81
|
let(:scenarios) { filter_messages_by_attribute(gherkin_document.feature.children, :scenario) }
|
85
82
|
let(:scenario) { scenarios.first }
|
86
83
|
|
@@ -112,8 +109,9 @@ describe Gherkin::Query do
|
|
112
109
|
|
113
110
|
context 'when querying tags' do
|
114
111
|
let(:feature_tag) { gherkin_document.feature.tags.first }
|
112
|
+
let(:rule_tag) { rule.tags.first }
|
115
113
|
let(:scenario_tag) { scenario.tags.first }
|
116
|
-
let(:
|
114
|
+
let(:examples_tag) { scenarios.last.examples.first.tags.first }
|
117
115
|
|
118
116
|
it 'provides the location of a feature tags' do
|
119
117
|
expect(subject.location(feature_tag.id)).to eq(feature_tag.location)
|
@@ -123,13 +121,16 @@ describe Gherkin::Query do
|
|
123
121
|
expect(subject.location(scenario_tag.id)).to eq(scenario_tag.location)
|
124
122
|
end
|
125
123
|
|
126
|
-
it 'provides the location of
|
127
|
-
expect(subject.location(
|
124
|
+
it 'provides the location of scenario examples tags' do
|
125
|
+
expect(subject.location(examples_tag.id)).to eq(examples_tag.location)
|
126
|
+
end
|
127
|
+
|
128
|
+
it 'provides the location of a rule tag' do
|
129
|
+
expect(subject.location(rule_tag.id)).to eq(rule_tag.location)
|
128
130
|
end
|
129
131
|
end
|
130
132
|
|
131
133
|
context 'when children are scoped in a Rule' do
|
132
|
-
let(:rule) { find_message_by_attribute(gherkin_document.feature.children, :rule) }
|
133
134
|
let(:rule_background) { find_message_by_attribute(rule.children, :background) }
|
134
135
|
let(:rule_background_step) { rule_background.steps.first }
|
135
136
|
let(:rule_scenario) { find_message_by_attribute(rule.children, :scenario) }
|
@@ -153,4 +154,4 @@ describe Gherkin::Query do
|
|
153
154
|
end
|
154
155
|
end
|
155
156
|
end
|
156
|
-
end
|
157
|
+
end
|
@@ -11,11 +11,11 @@ module Gherkin
|
|
11
11
|
}
|
12
12
|
|
13
13
|
let(:source_feature) {
|
14
|
-
Cucumber::Messages::Source.new(
|
14
|
+
Cucumber::Messages::Source.new(
|
15
15
|
uri: '//whatever/uri',
|
16
16
|
data: feature_content,
|
17
17
|
media_type: 'text/x.cucumber.gherkin+plain'
|
18
|
-
|
18
|
+
)
|
19
19
|
}
|
20
20
|
|
21
21
|
let(:options) {
|
@@ -64,4 +64,4 @@ module Gherkin
|
|
64
64
|
end
|
65
65
|
end
|
66
66
|
end
|
67
|
-
end
|
67
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cucumber-gherkin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 20.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gáspár Nagy
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2021-07-19 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: cucumber-messages
|
@@ -18,20 +18,20 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - "~>"
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: '
|
21
|
+
version: '17.0'
|
22
22
|
- - ">="
|
23
23
|
- !ruby/object:Gem::Version
|
24
|
-
version:
|
24
|
+
version: 17.0.1
|
25
25
|
type: :runtime
|
26
26
|
prerelease: false
|
27
27
|
version_requirements: !ruby/object:Gem::Requirement
|
28
28
|
requirements:
|
29
29
|
- - "~>"
|
30
30
|
- !ruby/object:Gem::Version
|
31
|
-
version: '
|
31
|
+
version: '17.0'
|
32
32
|
- - ">="
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version:
|
34
|
+
version: 17.0.1
|
35
35
|
- !ruby/object:Gem::Dependency
|
36
36
|
name: rake
|
37
37
|
requirement: !ruby/object:Gem::Requirement
|
@@ -41,7 +41,7 @@ dependencies:
|
|
41
41
|
version: '13.0'
|
42
42
|
- - ">="
|
43
43
|
- !ruby/object:Gem::Version
|
44
|
-
version: 13.0.
|
44
|
+
version: 13.0.6
|
45
45
|
type: :development
|
46
46
|
prerelease: false
|
47
47
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -51,27 +51,27 @@ dependencies:
|
|
51
51
|
version: '13.0'
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 13.0.
|
54
|
+
version: 13.0.6
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rspec
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '3.
|
61
|
+
version: '3.10'
|
62
62
|
- - ">="
|
63
63
|
- !ruby/object:Gem::Version
|
64
|
-
version: 3.
|
64
|
+
version: 3.10.0
|
65
65
|
type: :development
|
66
66
|
prerelease: false
|
67
67
|
version_requirements: !ruby/object:Gem::Requirement
|
68
68
|
requirements:
|
69
69
|
- - "~>"
|
70
70
|
- !ruby/object:Gem::Version
|
71
|
-
version: '3.
|
71
|
+
version: '3.10'
|
72
72
|
- - ">="
|
73
73
|
- !ruby/object:Gem::Version
|
74
|
-
version: 3.
|
74
|
+
version: 3.10.0
|
75
75
|
description: Gherkin parser
|
76
76
|
email: cukes@googlegroups.com
|
77
77
|
executables:
|
@@ -95,7 +95,6 @@ files:
|
|
95
95
|
- lib/gherkin/pickles/compiler.rb
|
96
96
|
- lib/gherkin/query.rb
|
97
97
|
- lib/gherkin/stream/parser_message_stream.rb
|
98
|
-
- lib/gherkin/stream/subprocess_message_stream.rb
|
99
98
|
- lib/gherkin/token.rb
|
100
99
|
- lib/gherkin/token_formatter_builder.rb
|
101
100
|
- lib/gherkin/token_matcher.rb
|
@@ -107,16 +106,15 @@ files:
|
|
107
106
|
- spec/gherkin/parser_spec.rb
|
108
107
|
- spec/gherkin/query_spec.rb
|
109
108
|
- spec/gherkin/stream/parser_message_stream_spec.rb
|
110
|
-
- spec/gherkin/stream/subprocess_message_stream_spec.rb
|
111
109
|
homepage: https://github.com/cucumber/gherkin-ruby
|
112
110
|
licenses:
|
113
111
|
- MIT
|
114
112
|
metadata:
|
115
113
|
bug_tracker_uri: https://github.com/cucumber/cucumber/issues
|
116
|
-
changelog_uri: https://github.com/cucumber/
|
114
|
+
changelog_uri: https://github.com/cucumber/common/blob/main/gherkin/CHANGELOG.md
|
117
115
|
documentation_uri: https://cucumber.io/docs/gherkin/
|
118
116
|
mailing_list_uri: https://groups.google.com/forum/#!forum/cukes
|
119
|
-
source_code_uri: https://github.com/cucumber/
|
117
|
+
source_code_uri: https://github.com/cucumber/common/blob/main/gherkin/ruby
|
120
118
|
post_install_message:
|
121
119
|
rdoc_options:
|
122
120
|
- "--charset=UTF-8"
|
@@ -136,13 +134,12 @@ requirements: []
|
|
136
134
|
rubygems_version: 3.1.2
|
137
135
|
signing_key:
|
138
136
|
specification_version: 4
|
139
|
-
summary: cucumber-gherkin-
|
137
|
+
summary: cucumber-gherkin-20.0.1
|
140
138
|
test_files:
|
141
|
-
- spec/
|
139
|
+
- spec/capture_warnings.rb
|
142
140
|
- spec/gherkin/gherkin_line_spec.rb
|
143
|
-
- spec/gherkin/
|
144
|
-
- spec/gherkin/stream/subprocess_message_stream_spec.rb
|
141
|
+
- spec/gherkin/dialect_spec.rb
|
145
142
|
- spec/gherkin/parser_spec.rb
|
146
|
-
- spec/gherkin/
|
143
|
+
- spec/gherkin/stream/parser_message_stream_spec.rb
|
147
144
|
- spec/gherkin/query_spec.rb
|
148
|
-
- spec/
|
145
|
+
- spec/gherkin/gherkin_spec.rb
|
@@ -1,26 +0,0 @@
|
|
1
|
-
require 'open3'
|
2
|
-
require 'cucumber/messages'
|
3
|
-
|
4
|
-
module Gherkin
|
5
|
-
module Stream
|
6
|
-
class SubprocessMessageStream
|
7
|
-
def initialize(gherkin_executable, paths, print_source, print_ast, print_pickles)
|
8
|
-
@gherkin_executable, @paths, @print_source, @print_ast, @print_pickles = gherkin_executable, paths, print_source, print_ast, print_pickles
|
9
|
-
end
|
10
|
-
|
11
|
-
def messages
|
12
|
-
args = [@gherkin_executable]
|
13
|
-
args.push('--no-source') unless @print_source
|
14
|
-
args.push('--no-ast') unless @print_ast
|
15
|
-
args.push('--no-pickles') unless @print_pickles
|
16
|
-
args = args.concat(@paths)
|
17
|
-
stdin, stdout, stderr, wait_thr = Open3.popen3(*args)
|
18
|
-
if(stdout.eof?)
|
19
|
-
error = stderr.read
|
20
|
-
raise error
|
21
|
-
end
|
22
|
-
Cucumber::Messages::BinaryToMessageEnumerator.new(stdout)
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|