gherkin 5.1.0 → 6.0.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -4
- data/bin/gherkin +43 -16
- data/gherkin-go/gherkin-go-darwin-386 +0 -0
- data/gherkin-go/gherkin-go-darwin-amd64 +0 -0
- data/gherkin-go/gherkin-go-freebsd-386 +0 -0
- data/gherkin-go/gherkin-go-freebsd-amd64 +0 -0
- data/gherkin-go/gherkin-go-freebsd-arm +0 -0
- data/gherkin-go/gherkin-go-linux-386 +0 -0
- data/gherkin-go/gherkin-go-linux-amd64 +0 -0
- data/gherkin-go/gherkin-go-linux-arm +0 -0
- data/gherkin-go/gherkin-go-linux-mips +2 -0
- data/gherkin-go/gherkin-go-linux-mips64 +2 -0
- data/gherkin-go/gherkin-go-linux-mips64le +2 -0
- data/gherkin-go/gherkin-go-linux-mipsle +2 -0
- data/gherkin-go/gherkin-go-linux-s390x +2 -0
- data/gherkin-go/gherkin-go-netbsd-386 +0 -0
- data/gherkin-go/gherkin-go-netbsd-amd64 +0 -0
- data/gherkin-go/gherkin-go-netbsd-arm +0 -0
- data/gherkin-go/gherkin-go-openbsd-386 +0 -0
- data/gherkin-go/gherkin-go-openbsd-amd64 +0 -0
- data/gherkin-go/gherkin-go-windows-386.exe +0 -0
- data/gherkin-go/gherkin-go-windows-amd64.exe +0 -0
- data/lib/gherkin/dialect.rb +16 -2
- data/lib/gherkin/exe_file_path.rb +3 -0
- data/lib/gherkin/gherkin.rb +75 -0
- data/lib/gherkin/protobuf_cucumber_messages.rb +30 -0
- data/spec/capture_warnings.rb +11 -5
- data/spec/coverage.rb +3 -6
- data/spec/gherkin/dialect_spec.rb +13 -0
- data/spec/gherkin/gherkin_spec.rb +354 -0
- metadata +49 -27
- data/lib/gherkin/ast_builder.rb +0 -257
- data/lib/gherkin/ast_node.rb +0 -30
- data/lib/gherkin/errors.rb +0 -45
- data/lib/gherkin/gherkin-languages.json +0 -3239
- data/lib/gherkin/gherkin_line.rb +0 -95
- data/lib/gherkin/parser.rb +0 -2310
- data/lib/gherkin/pickles/compiler.rb +0 -163
- data/lib/gherkin/stream/gherkin_events.rb +0 -71
- data/lib/gherkin/stream/source_events.rb +0 -26
- data/lib/gherkin/token.rb +0 -18
- data/lib/gherkin/token_formatter_builder.rb +0 -39
- data/lib/gherkin/token_matcher.rb +0 -169
- data/lib/gherkin/token_scanner.rb +0 -40
- data/spec/gherkin/parser_spec.rb +0 -280
- data/spec/gherkin/stream/gherkin_events_spec.rb +0 -27
- data/spec/gherkin/stream/test_fr.feature +0 -3
@@ -1,40 +0,0 @@
|
|
1
|
-
require 'stringio'
|
2
|
-
require 'gherkin/token'
|
3
|
-
require 'gherkin/gherkin_line'
|
4
|
-
|
5
|
-
module Gherkin
|
6
|
-
# The scanner reads a gherkin doc (typically read from a .feature file) and
|
7
|
-
# creates a token for line. The tokens are passed to the parser, which outputs
|
8
|
-
# an AST (Abstract Syntax Tree).
|
9
|
-
#
|
10
|
-
# If the scanner sees a # language header, it will reconfigure itself dynamically
|
11
|
-
# to look for Gherkin keywords for the associated language. The keywords are defined
|
12
|
-
# in gherkin-languages.json.
|
13
|
-
class TokenScanner
|
14
|
-
def initialize(source_or_io)
|
15
|
-
@line_number = 0
|
16
|
-
|
17
|
-
case(source_or_io)
|
18
|
-
when String
|
19
|
-
@io = StringIO.new(source_or_io)
|
20
|
-
when StringIO, IO
|
21
|
-
@io = source_or_io
|
22
|
-
else
|
23
|
-
fail ArgumentError, "Please a pass String, StringIO or IO. I got a #{source_or_io.class}"
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
def read
|
28
|
-
location = {line: @line_number += 1, column: 0}
|
29
|
-
if @io.nil? || line = @io.gets
|
30
|
-
gherkin_line = line ? GherkinLine.new(line, location[:line]) : nil
|
31
|
-
Token.new(gherkin_line, location)
|
32
|
-
else
|
33
|
-
@io.close unless @io.closed? # ARGF closes the last file after final gets
|
34
|
-
@io = nil
|
35
|
-
Token.new(nil, location)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
end
|
40
|
-
end
|
data/spec/gherkin/parser_spec.rb
DELETED
@@ -1,280 +0,0 @@
|
|
1
|
-
require 'gherkin/parser'
|
2
|
-
require 'gherkin/token_scanner'
|
3
|
-
require 'gherkin/token_matcher'
|
4
|
-
require 'gherkin/ast_builder'
|
5
|
-
require 'gherkin/errors'
|
6
|
-
require 'rspec'
|
7
|
-
|
8
|
-
module Gherkin
|
9
|
-
describe Parser do
|
10
|
-
it "parses a simple feature" do
|
11
|
-
parser = Parser.new
|
12
|
-
scanner = TokenScanner.new("Feature: test")
|
13
|
-
ast = parser.parse(scanner)
|
14
|
-
expect(ast).to eq({
|
15
|
-
feature: {
|
16
|
-
type: :Feature,
|
17
|
-
tags: [],
|
18
|
-
location: {line: 1, column: 1},
|
19
|
-
language: "en",
|
20
|
-
keyword: "Feature",
|
21
|
-
name: "test",
|
22
|
-
children: []
|
23
|
-
},
|
24
|
-
comments: [],
|
25
|
-
type: :GherkinDocument
|
26
|
-
})
|
27
|
-
end
|
28
|
-
|
29
|
-
it "parses a complex feature" do
|
30
|
-
# This should include every significant type of thing within the language
|
31
|
-
feature_text = "@feature_tag\n" +
|
32
|
-
"Feature: feature name\n" +
|
33
|
-
" feature description\n" +
|
34
|
-
"\n" +
|
35
|
-
" Background: background name\n" +
|
36
|
-
" background description\n" +
|
37
|
-
" * a step\n" +
|
38
|
-
"\n" +
|
39
|
-
" @scenario_tag\n" +
|
40
|
-
" Scenario: scenario name\n" +
|
41
|
-
" scenario description\n" +
|
42
|
-
" * a step with a table\n" +
|
43
|
-
" | a table |\n" +
|
44
|
-
"\n" +
|
45
|
-
" @outline_tag\n" +
|
46
|
-
" Scenario Outline: outline name\n" +
|
47
|
-
" outline description\n" +
|
48
|
-
" * a step with a doc string\n" +
|
49
|
-
" \"\"\" content_type\n" +
|
50
|
-
" lots of text\n" +
|
51
|
-
" \"\"\"\n" +
|
52
|
-
" # Random file comment\n" +
|
53
|
-
" @example_tag\n" +
|
54
|
-
" Examples: examples name\n" +
|
55
|
-
" examples description\n" +
|
56
|
-
" | param |\n" +
|
57
|
-
" | value |\n"
|
58
|
-
|
59
|
-
parser = Parser.new
|
60
|
-
scanner = TokenScanner.new(feature_text)
|
61
|
-
ast = parser.parse(scanner)
|
62
|
-
|
63
|
-
expect(ast).to eq({
|
64
|
-
feature: {type: :Feature,
|
65
|
-
tags: [{type: :Tag,
|
66
|
-
location: {line: 1, column: 1},
|
67
|
-
name: "@feature_tag"}],
|
68
|
-
location: {line: 2, column: 1},
|
69
|
-
language: "en",
|
70
|
-
keyword: "Feature",
|
71
|
-
name: "feature name",
|
72
|
-
description: " feature description",
|
73
|
-
children: [{type: :Background,
|
74
|
-
location: {line: 5, column: 4},
|
75
|
-
keyword: "Background",
|
76
|
-
name: "background name",
|
77
|
-
description: " background description",
|
78
|
-
steps: [{type: :Step,
|
79
|
-
location: {line: 7, column: 5},
|
80
|
-
keyword: "* ",
|
81
|
-
text: "a step"}]},
|
82
|
-
{type: :Scenario,
|
83
|
-
tags: [{type: :Tag,
|
84
|
-
location: {line: 9, column: 3},
|
85
|
-
name: "@scenario_tag"}],
|
86
|
-
location: {line: 10, column: 3},
|
87
|
-
keyword: "Scenario",
|
88
|
-
name: "scenario name",
|
89
|
-
description: " scenario description",
|
90
|
-
steps: [{type: :Step,
|
91
|
-
location: {line: 12, column: 5},
|
92
|
-
keyword: "* ",
|
93
|
-
text: "a step with a table",
|
94
|
-
argument: {type: :DataTable,
|
95
|
-
location: {line: 13, column: 7},
|
96
|
-
rows: [{type: :TableRow,
|
97
|
-
location: {line: 13, column: 7},
|
98
|
-
cells: [{type: :TableCell,
|
99
|
-
location: {line: 13, column: 9},
|
100
|
-
value: "a table"}]}]}}]},
|
101
|
-
{type: :ScenarioOutline,
|
102
|
-
tags: [{type: :Tag,
|
103
|
-
location: {line: 15, column: 3},
|
104
|
-
name: "@outline_tag"}],
|
105
|
-
location: {line: 16, column: 3},
|
106
|
-
keyword: "Scenario Outline",
|
107
|
-
name: "outline name",
|
108
|
-
description: " outline description",
|
109
|
-
steps: [{type: :Step,
|
110
|
-
location: {line: 18, column: 5},
|
111
|
-
keyword: "* ",
|
112
|
-
text: "a step with a doc string",
|
113
|
-
argument: {type: :DocString,
|
114
|
-
location: {line: 19, column: 7},
|
115
|
-
contentType: "content_type",
|
116
|
-
content: " lots of text"}}],
|
117
|
-
examples: [{type: :Examples,
|
118
|
-
tags: [{type: :Tag,
|
119
|
-
location: {line: 23, column: 3},
|
120
|
-
name: "@example_tag"}],
|
121
|
-
location: {line: 24, column: 3},
|
122
|
-
keyword: "Examples",
|
123
|
-
name: "examples name",
|
124
|
-
description: " examples description",
|
125
|
-
tableHeader: {type: :TableRow,
|
126
|
-
location: {line: 26, column: 5},
|
127
|
-
cells: [{type: :TableCell,
|
128
|
-
location: {line: 26, column: 7},
|
129
|
-
value: "param"}]},
|
130
|
-
tableBody: [{type: :TableRow,
|
131
|
-
location: {line: 27, column: 5},
|
132
|
-
cells: [{type: :TableCell,
|
133
|
-
location: {line: 27, column: 7},
|
134
|
-
value: "value"}]}]}]}],
|
135
|
-
},
|
136
|
-
comments: [{type: :Comment,
|
137
|
-
location: {line: 22, column: 1},
|
138
|
-
text: " # Random file comment"}],
|
139
|
-
type: :GherkinDocument}
|
140
|
-
)
|
141
|
-
end
|
142
|
-
|
143
|
-
it "parses string feature" do
|
144
|
-
parser = Parser.new
|
145
|
-
ast = parser.parse("Feature: test")
|
146
|
-
expect(ast).to eq({
|
147
|
-
feature: {
|
148
|
-
type: :Feature,
|
149
|
-
tags: [],
|
150
|
-
location: {line: 1, column: 1},
|
151
|
-
language: "en",
|
152
|
-
keyword: "Feature",
|
153
|
-
name: "test",
|
154
|
-
children: []
|
155
|
-
},
|
156
|
-
comments: [],
|
157
|
-
type: :GherkinDocument
|
158
|
-
})
|
159
|
-
end
|
160
|
-
|
161
|
-
it "parses io feature" do
|
162
|
-
parser = Parser.new
|
163
|
-
ast = parser.parse(StringIO.new("Feature: test"))
|
164
|
-
expect(ast).to eq({
|
165
|
-
feature: {
|
166
|
-
type: :Feature,
|
167
|
-
tags: [],
|
168
|
-
location: {line: 1, column: 1},
|
169
|
-
language: "en",
|
170
|
-
keyword: "Feature",
|
171
|
-
name: "test",
|
172
|
-
children: []
|
173
|
-
},
|
174
|
-
comments: [],
|
175
|
-
type: :GherkinDocument
|
176
|
-
})
|
177
|
-
end
|
178
|
-
|
179
|
-
it "can parse multiple features" do
|
180
|
-
parser = Parser.new
|
181
|
-
ast1 = parser.parse(TokenScanner.new("Feature: test"))
|
182
|
-
ast2 = parser.parse(TokenScanner.new("Feature: test2"))
|
183
|
-
|
184
|
-
expect(ast1).to eq({
|
185
|
-
feature: {
|
186
|
-
type: :Feature,
|
187
|
-
tags: [],
|
188
|
-
location: {line: 1, column: 1},
|
189
|
-
language: "en",
|
190
|
-
keyword: "Feature",
|
191
|
-
name: "test",
|
192
|
-
children: []
|
193
|
-
},
|
194
|
-
comments: [],
|
195
|
-
type: :GherkinDocument
|
196
|
-
})
|
197
|
-
expect(ast2).to eq({
|
198
|
-
feature: {
|
199
|
-
type: :Feature,
|
200
|
-
tags: [],
|
201
|
-
location: {line: 1, column: 1},
|
202
|
-
language: "en",
|
203
|
-
keyword: "Feature",
|
204
|
-
name: "test2",
|
205
|
-
children: []
|
206
|
-
},
|
207
|
-
comments: [],
|
208
|
-
type: :GherkinDocument
|
209
|
-
})
|
210
|
-
end
|
211
|
-
|
212
|
-
it "can parse feature after parse error" do
|
213
|
-
parser = Parser.new
|
214
|
-
matcher = TokenMatcher.new
|
215
|
-
|
216
|
-
expect { parser.parse(TokenScanner.new("# a comment\n" +
|
217
|
-
"Feature: Foo\n" +
|
218
|
-
" Scenario: Bar\n" +
|
219
|
-
" Given x\n" +
|
220
|
-
" ```\n" +
|
221
|
-
" unclosed docstring\n"),
|
222
|
-
matcher)
|
223
|
-
}.to raise_error(ParserError)
|
224
|
-
ast = parser.parse(TokenScanner.new("Feature: Foo\n" +
|
225
|
-
" Scenario: Bar\n" +
|
226
|
-
" Given x\n" +
|
227
|
-
' """' + "\n" +
|
228
|
-
" closed docstring\n" +
|
229
|
-
' """' + "\n"),
|
230
|
-
matcher)
|
231
|
-
|
232
|
-
expect(ast).to eq({
|
233
|
-
feature: {
|
234
|
-
type: :Feature,
|
235
|
-
tags: [],
|
236
|
-
location: {line: 1, column: 1},
|
237
|
-
language: "en",
|
238
|
-
keyword: "Feature",
|
239
|
-
name: "Foo",
|
240
|
-
children: [{
|
241
|
-
:type=>:Scenario,
|
242
|
-
:tags=>[],
|
243
|
-
:location=>{:line=>2, :column=>3},
|
244
|
-
:keyword=>"Scenario",
|
245
|
-
:name=>"Bar",
|
246
|
-
:steps=>[{
|
247
|
-
:type=>:Step,
|
248
|
-
:location=>{:line=>3, :column=>5},
|
249
|
-
:keyword=>"Given ",
|
250
|
-
:text=>"x",
|
251
|
-
:argument=>{:type=>:DocString,
|
252
|
-
:location=>{:line=>4, :column=>7},
|
253
|
-
:content=>"closed docstring"}}]}]
|
254
|
-
},
|
255
|
-
comments: [],
|
256
|
-
type: :GherkinDocument
|
257
|
-
})
|
258
|
-
end
|
259
|
-
|
260
|
-
it "can change the default language" do
|
261
|
-
parser = Parser.new
|
262
|
-
matcher = TokenMatcher.new("no")
|
263
|
-
scanner = TokenScanner.new("Egenskap: i18n support")
|
264
|
-
ast = parser.parse(scanner, matcher)
|
265
|
-
expect(ast).to eq({
|
266
|
-
feature: {
|
267
|
-
type: :Feature,
|
268
|
-
tags: [],
|
269
|
-
location: {line: 1, column: 1},
|
270
|
-
language: "no",
|
271
|
-
keyword: "Egenskap",
|
272
|
-
name: "i18n support",
|
273
|
-
children: []
|
274
|
-
},
|
275
|
-
comments: [],
|
276
|
-
type: :GherkinDocument
|
277
|
-
})
|
278
|
-
end
|
279
|
-
end
|
280
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
require 'rspec'
|
2
|
-
require 'gherkin/stream/gherkin_events'
|
3
|
-
require 'gherkin/stream/source_events'
|
4
|
-
|
5
|
-
module Gherkin
|
6
|
-
module Stream
|
7
|
-
describe GherkinEvents do
|
8
|
-
it "accepts a language parameter" do
|
9
|
-
source_events = SourceEvents.new([File.dirname(__FILE__) + '/test_fr.feature'])
|
10
|
-
gherkin_events = GherkinEvents.new({
|
11
|
-
print_source: true,
|
12
|
-
print_ast: true,
|
13
|
-
print_pickles: true
|
14
|
-
}, 'fr')
|
15
|
-
|
16
|
-
event_types = []
|
17
|
-
source_events.enum.each do |source_event|
|
18
|
-
gherkin_events.enum(source_event).each do |event|
|
19
|
-
event_types << event[:type]
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
expect(event_types).to eq(['source', 'gherkin-document', 'pickle'])
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|