cucumber-gherkin 18.1.1 → 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 +27 -28
- data/lib/gherkin/gherkin-languages.json +46 -4
- data/lib/gherkin/gherkin_line.rb +1 -1
- data/lib/gherkin/parser.rb +52 -104
- data/lib/gherkin/pickles/compiler.rb +10 -10
- 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/query_spec.rb +24 -23
- data/spec/gherkin/stream/parser_message_stream_spec.rb +3 -3
- metadata +11 -14
- data/lib/gherkin/stream/subprocess_message_stream.rb +0 -26
- data/spec/gherkin/stream/subprocess_message_stream_spec.rb +0 -18
@@ -84,9 +84,9 @@ module Gherkin
|
|
84
84
|
steps = scenario.steps.empty? ? [] : [].concat(pickle_steps(background_steps))
|
85
85
|
tags = [].concat(inherited_tags).concat(scenario.tags).concat(examples.tags)
|
86
86
|
|
87
|
-
scenario.steps.each do |
|
88
|
-
step_props = pickle_step_props(
|
89
|
-
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))
|
90
90
|
end
|
91
91
|
|
92
92
|
pickle = Cucumber::Messages::Pickle.new(
|
@@ -99,7 +99,7 @@ module Gherkin
|
|
99
99
|
ast_node_ids: [
|
100
100
|
scenario.id,
|
101
101
|
values_row.id
|
102
|
-
]
|
102
|
+
]
|
103
103
|
)
|
104
104
|
pickles.push(pickle)
|
105
105
|
|
@@ -122,7 +122,7 @@ module Gherkin
|
|
122
122
|
end
|
123
123
|
|
124
124
|
def pickle_step(step)
|
125
|
-
Cucumber::Messages::
|
125
|
+
Cucumber::Messages::PickleStep.new(**pickle_step_props(step, [], nil))
|
126
126
|
end
|
127
127
|
|
128
128
|
def pickle_step_props(step, variable_cells, values_row)
|
@@ -152,11 +152,11 @@ module Gherkin
|
|
152
152
|
end
|
153
153
|
|
154
154
|
def pickle_data_table(data_table, variable_cells, value_cells)
|
155
|
-
Cucumber::Messages::
|
155
|
+
Cucumber::Messages::PickleTable.new(
|
156
156
|
rows: data_table.rows.map do |row|
|
157
|
-
Cucumber::Messages::
|
157
|
+
Cucumber::Messages::PickleTableRow.new(
|
158
158
|
cells: row.cells.map do |cell|
|
159
|
-
Cucumber::Messages::
|
159
|
+
Cucumber::Messages::PickleTableCell.new(
|
160
160
|
value: interpolate(cell.value, variable_cells, value_cells)
|
161
161
|
)
|
162
162
|
end
|
@@ -172,7 +172,7 @@ module Gherkin
|
|
172
172
|
if doc_string.media_type
|
173
173
|
props[:media_type] = interpolate(doc_string.media_type, variable_cells, value_cells)
|
174
174
|
end
|
175
|
-
Cucumber::Messages::
|
175
|
+
Cucumber::Messages::PickleDocString.new(**props)
|
176
176
|
end
|
177
177
|
|
178
178
|
def pickle_tags(tags)
|
@@ -180,7 +180,7 @@ module Gherkin
|
|
180
180
|
end
|
181
181
|
|
182
182
|
def pickle_tag(tag)
|
183
|
-
Cucumber::Messages::
|
183
|
+
Cucumber::Messages::PickleTag.new(
|
184
184
|
name: tag.name,
|
185
185
|
ast_node_id: tag.id
|
186
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)
|
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: 2021-
|
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,7 +51,7 @@ 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
|
@@ -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
139
|
- spec/capture_warnings.rb
|
142
140
|
- spec/gherkin/gherkin_line_spec.rb
|
143
141
|
- spec/gherkin/dialect_spec.rb
|
144
142
|
- spec/gherkin/parser_spec.rb
|
145
143
|
- spec/gherkin/stream/parser_message_stream_spec.rb
|
146
|
-
- spec/gherkin/stream/subprocess_message_stream_spec.rb
|
147
144
|
- spec/gherkin/query_spec.rb
|
148
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
|
@@ -1,18 +0,0 @@
|
|
1
|
-
require 'rspec'
|
2
|
-
require 'gherkin/stream/subprocess_message_stream'
|
3
|
-
|
4
|
-
module Gherkin
|
5
|
-
module Stream
|
6
|
-
describe SubprocessMessageStream do
|
7
|
-
it "works" do
|
8
|
-
cucumber_messages = SubprocessMessageStream.new(
|
9
|
-
"./bin/gherkin",
|
10
|
-
["testdata/good/minimal.feature"],
|
11
|
-
true, true, true
|
12
|
-
)
|
13
|
-
messages = cucumber_messages.messages.to_a
|
14
|
-
expect(messages.length).to eq(3)
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|