gherkin-ruby 0.1.0 → 0.2.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.
- data/.rvmrc +1 -0
- data/.travis.yml +1 -2
- data/Rakefile +1 -1
- data/Readme.md +3 -1
- data/gherkin-ruby.gemspec +4 -4
- data/lib/gherkin/ast.rb +4 -3
- data/lib/gherkin/parser/gherkin.rex +1 -1
- data/lib/gherkin/parser/gherkin.y +11 -3
- data/lib/gherkin/parser/lexer.rb +1 -1
- data/lib/gherkin/parser/parser.rb +165 -131
- data/lib/gherkin/version.rb +1 -1
- data/test/gherkin/ast_test.rb +13 -11
- data/test/gherkin/parser/lexer_test.rb +9 -7
- data/test/gherkin/parser/parser_test.rb +39 -3
- metadata +64 -77
data/.rvmrc
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
rvm use --create 1.9.3@gherkin-ruby
|
data/.travis.yml
CHANGED
data/Rakefile
CHANGED
@@ -15,7 +15,7 @@ task :regenerate do
|
|
15
15
|
|
16
16
|
if has_rex && has_racc
|
17
17
|
`rex lib/gherkin/parser/gherkin.rex -o lib/gherkin/parser/lexer.rb`
|
18
|
-
`racc lib/gherkin/parser/gherkin.y -o lib/gherkin/parser/parser.rb`
|
18
|
+
`racc #{'--debug' if ENV['DEBUG_RACC']} lib/gherkin/parser/gherkin.y -o lib/gherkin/parser/parser.rb`
|
19
19
|
else
|
20
20
|
puts "You need both Rexical and Racc to do that. Install them by doing:"
|
21
21
|
puts
|
data/Readme.md
CHANGED
@@ -1,6 +1,8 @@
|
|
1
|
-
# gherkin-ruby
|
1
|
+
# gherkin-ruby [](http://travis-ci.org/codegram/gherkin-ruby) [](http://gemnasium.com/codegram/gherkin-ruby)
|
2
2
|
Gherkin-ruby is a pure Ruby implementation of a [Gherkin](http://github.com/cucumber/gherkin) parser.
|
3
3
|
|
4
|
+
Tested with MRI 1.9.2, 1.9.3, ruby-head and Rubinius head.
|
5
|
+
|
4
6
|
## Why this one over the official, fast, Ragel-based Gherkin parser?
|
5
7
|
|
6
8
|
* Less than 200 LOC.
|
data/gherkin-ruby.gemspec
CHANGED
@@ -7,15 +7,15 @@ Gem::Specification.new do |s|
|
|
7
7
|
s.version = Gherkin::VERSION
|
8
8
|
s.authors = ["Marc Divins", "Josep M. Bach"]
|
9
9
|
s.email = ["marcdivc@gmail.com", "josep.m.bach@gmail.com"]
|
10
|
-
s.homepage = "http://github.com/codegram/gherkin"
|
11
|
-
s.summary = %q{Gherkin-ruby is a Gherkin parser in pure Ruby using
|
12
|
-
s.description = %q{Gherkin-ruby is a Gherkin parser in pure Ruby using
|
10
|
+
s.homepage = "http://github.com/codegram/gherkin-ruby"
|
11
|
+
s.summary = %q{Gherkin-ruby is a Gherkin parser in pure Ruby using Rexical and Racc}
|
12
|
+
s.description = %q{Gherkin-ruby is a Gherkin parser in pure Ruby using Rexical and Racc}
|
13
13
|
|
14
14
|
s.rubyforge_project = "gherkin-ruby"
|
15
15
|
|
16
16
|
s.add_runtime_dependency 'rexical'
|
17
|
-
s.add_runtime_dependency 'racc'
|
18
17
|
s.add_development_dependency 'minitest'
|
18
|
+
s.add_development_dependency 'racc'
|
19
19
|
|
20
20
|
s.files = `git ls-files`.split("\n")
|
21
21
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
data/lib/gherkin/ast.rb
CHANGED
@@ -14,14 +14,15 @@ module Gherkin
|
|
14
14
|
end
|
15
15
|
|
16
16
|
class Feature < Node
|
17
|
-
attr_reader :name, :background, :scenarios
|
18
|
-
attr_writer :background, :scenarios
|
17
|
+
attr_reader :name, :background, :scenarios, :tags
|
18
|
+
attr_writer :background, :scenarios, :tags
|
19
19
|
|
20
20
|
include Enumerable
|
21
21
|
|
22
|
-
def initialize(name, scenarios=[], background=nil)
|
22
|
+
def initialize(name, scenarios=[], tags=[], background=nil)
|
23
23
|
@name = name
|
24
24
|
@background = background
|
25
|
+
@tags = tags
|
25
26
|
@scenarios = scenarios
|
26
27
|
end
|
27
28
|
|
@@ -16,6 +16,9 @@ rule
|
|
16
16
|
|
|
17
17
|
Feature
|
18
18
|
Scenarios { result = val[0]; result.scenarios = val[1] }
|
19
|
+
| FeatureTags Feature { result = val[1]; result.tags = val[0] }
|
20
|
+
| FeatureTags Feature
|
21
|
+
Scenarios { result = val[1]; result.scenarios = val[2]; result.tags = val[0] }
|
19
22
|
;
|
20
23
|
|
21
24
|
Newline:
|
@@ -23,6 +26,10 @@ rule
|
|
23
26
|
| Newline NEWLINE
|
24
27
|
;
|
25
28
|
|
29
|
+
FeatureTags:
|
30
|
+
Tags { result = val[0] }
|
31
|
+
| Newline Tags { result = val[1] }
|
32
|
+
|
26
33
|
Feature:
|
27
34
|
FeatureHeader { result = val[0] }
|
28
35
|
| FeatureHeader
|
@@ -56,8 +63,9 @@ rule
|
|
56
63
|
;
|
57
64
|
|
58
65
|
Steps:
|
59
|
-
Step
|
60
|
-
|
|
66
|
+
Step { result = [val[0]] }
|
67
|
+
| Step Newline { result = [val[0]] }
|
68
|
+
| Step Newline Steps { val[2].unshift(val[0]); result = val[2] }
|
61
69
|
;
|
62
70
|
|
63
71
|
Step:
|
@@ -71,7 +79,6 @@ rule
|
|
71
79
|
Scenarios:
|
72
80
|
Scenario { result = [val[0]] }
|
73
81
|
| Scenarios Scenario { result = val[0] << val[1] }
|
74
|
-
| Scenarios Newline Scenario { result = val[0] << val[2] }
|
75
82
|
;
|
76
83
|
|
77
84
|
Scenario:
|
@@ -96,5 +103,6 @@ end
|
|
96
103
|
---- inner
|
97
104
|
|
98
105
|
def parse(input)
|
106
|
+
@yydebug = true if ENV['DEBUG_RACC']
|
99
107
|
scan_str(input)
|
100
108
|
end
|
data/lib/gherkin/parser/lexer.rb
CHANGED
@@ -77,7 +77,7 @@ class Gherkin::Parser < Racc::Parser
|
|
77
77
|
when (text = @ss.scan(/Scenario:/))
|
78
78
|
action { [:SCENARIO, text[0..-2]] }
|
79
79
|
|
80
|
-
when (text = @ss.scan(
|
80
|
+
when (text = @ss.scan(/@(\w|-)+/))
|
81
81
|
action { [:TAG, text[1..-1]] }
|
82
82
|
|
83
83
|
when (text = @ss.scan(/Given/))
|
@@ -1,6 +1,6 @@
|
|
1
1
|
#
|
2
2
|
# DO NOT MODIFY!!!!
|
3
|
-
# This file is automatically generated by Racc 1.4.
|
3
|
+
# This file is automatically generated by Racc 1.4.8
|
4
4
|
# from Racc grammer file "".
|
5
5
|
#
|
6
6
|
|
@@ -12,108 +12,113 @@ require 'racc/parser.rb'
|
|
12
12
|
module Gherkin
|
13
13
|
class Parser < Racc::Parser
|
14
14
|
|
15
|
-
module_eval(<<'...end gherkin.y/module_eval...', 'gherkin.y',
|
15
|
+
module_eval(<<'...end gherkin.y/module_eval...', 'gherkin.y', 104)
|
16
16
|
|
17
17
|
def parse(input)
|
18
|
+
@yydebug = true if ENV['DEBUG_RACC']
|
18
19
|
scan_str(input)
|
19
20
|
end
|
20
21
|
...end gherkin.y/module_eval...
|
21
22
|
##### State transition tables begin ###
|
22
23
|
|
23
24
|
racc_action_table = [
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
8, 24 ]
|
25
|
+
18, 18, 20, 4, 26, 10, 18, 21, 14, 10,
|
26
|
+
43, 36, 37, 38, 39, 40, 18, 18, 14, 10,
|
27
|
+
45, 36, 37, 38, 39, 40, 18, 14, 10, 4,
|
28
|
+
9, 36, 37, 38, 39, 40, 36, 37, 38, 39,
|
29
|
+
40, 4, 9, 14, 10, 10, 18, 20, 32, 24,
|
30
|
+
21, 4, 4, 29, 21, 4, 47, 18, 48, 4,
|
31
|
+
27, 51, 11, 4, 18, 4, 18, 4 ]
|
32
32
|
|
33
33
|
racc_action_check = [
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
1, 11 ]
|
34
|
+
25, 5, 5, 15, 9, 5, 54, 15, 31, 31,
|
35
|
+
25, 54, 54, 54, 54, 54, 44, 30, 12, 12,
|
36
|
+
30, 44, 44, 44, 44, 44, 46, 2, 2, 3,
|
37
|
+
3, 46, 46, 46, 46, 46, 23, 23, 23, 23,
|
38
|
+
23, 0, 0, 16, 16, 0, 17, 17, 20, 7,
|
39
|
+
6, 8, 29, 14, 19, 34, 35, 41, 42, 43,
|
40
|
+
11, 45, 1, 48, 49, 51, 53, 24 ]
|
42
41
|
|
43
42
|
racc_action_pointer = [
|
44
|
-
|
45
|
-
nil,
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
43
|
+
39, 62, 22, 27, nil, -1, 44, 45, 49, -8,
|
44
|
+
nil, 60, 13, nil, 41, 1, 38, 44, nil, 48,
|
45
|
+
36, nil, nil, 29, 65, -2, nil, nil, nil, 50,
|
46
|
+
15, 3, nil, nil, 53, 44, nil, nil, nil, nil,
|
47
|
+
nil, 55, 46, 57, 14, 49, 24, nil, 61, 62,
|
48
|
+
nil, 63, nil, 64, 4, nil ]
|
50
49
|
|
51
50
|
racc_action_default = [
|
52
|
-
-
|
53
|
-
-
|
54
|
-
-
|
55
|
-
-
|
56
|
-
-
|
57
|
-
-
|
51
|
+
-35, -35, -1, -35, -5, -35, -7, -9, -11, -35,
|
52
|
+
-33, -35, -2, -29, -35, -35, -3, -35, -6, -8,
|
53
|
+
-35, -34, -10, -35, -35, -12, -14, 56, -30, -35,
|
54
|
+
-35, -4, -15, -18, -20, -35, -24, -25, -26, -27,
|
55
|
+
-28, -19, -13, -35, -35, -35, -21, -23, -35, -16,
|
56
|
+
-31, -35, -22, -17, -35, -32 ]
|
58
57
|
|
59
58
|
racc_goto_table = [
|
60
|
-
|
61
|
-
|
62
|
-
nil,
|
63
|
-
nil, nil, nil, nil, nil, nil,
|
64
|
-
nil, nil, 49, nil, nil,
|
59
|
+
5, 28, 33, 17, 12, 6, 2, 23, 25, 16,
|
60
|
+
19, 42, 22, 3, 1, 30, nil, nil, 31, nil,
|
61
|
+
28, nil, nil, 50, 41, 52, nil, nil, nil, 44,
|
62
|
+
nil, nil, nil, 55, 46, nil, nil, nil, nil, nil,
|
63
|
+
nil, nil, nil, 49, nil, nil, nil, nil, 53, nil,
|
64
|
+
nil, 54 ]
|
65
65
|
|
66
66
|
racc_goto_check = [
|
67
|
-
|
68
|
-
|
69
|
-
nil,
|
70
|
-
nil, nil, nil, nil, nil, nil,
|
71
|
-
nil, nil,
|
67
|
+
5, 15, 12, 5, 3, 6, 2, 11, 5, 2,
|
68
|
+
6, 10, 8, 4, 1, 5, nil, nil, 3, nil,
|
69
|
+
15, nil, nil, 12, 5, 12, nil, nil, nil, 5,
|
70
|
+
nil, nil, nil, 12, 5, nil, nil, nil, nil, nil,
|
71
|
+
nil, nil, nil, 5, nil, nil, nil, nil, 5, nil,
|
72
|
+
nil, 5 ]
|
72
73
|
|
73
74
|
racc_goto_pointer = [
|
74
|
-
nil,
|
75
|
-
-
|
75
|
+
nil, 14, 6, 2, 13, 0, 5, nil, 5, nil,
|
76
|
+
-14, 0, -21, nil, nil, -11 ]
|
76
77
|
|
77
78
|
racc_goto_default = [
|
78
|
-
nil, nil, nil, nil, nil, nil,
|
79
|
-
nil,
|
79
|
+
nil, nil, nil, nil, nil, nil, 15, 7, nil, 8,
|
80
|
+
nil, nil, nil, 34, 35, 13 ]
|
80
81
|
|
81
82
|
racc_reduce_table = [
|
82
83
|
0, 0, :racc_error,
|
83
84
|
1, 14, :_reduce_1,
|
84
85
|
2, 14, :_reduce_2,
|
85
|
-
|
86
|
-
|
87
|
-
1,
|
88
|
-
2,
|
89
|
-
1,
|
90
|
-
2,
|
91
|
-
|
92
|
-
2,
|
93
|
-
|
94
|
-
2,
|
95
|
-
3,
|
96
|
-
2,
|
97
|
-
|
98
|
-
2, 23, :
|
99
|
-
3, 23, :
|
100
|
-
2,
|
101
|
-
|
102
|
-
1, 25, :
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
1,
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
1,
|
112
|
-
2,
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
86
|
+
2, 14, :_reduce_3,
|
87
|
+
3, 14, :_reduce_4,
|
88
|
+
1, 18, :_reduce_none,
|
89
|
+
2, 18, :_reduce_none,
|
90
|
+
1, 17, :_reduce_7,
|
91
|
+
2, 17, :_reduce_8,
|
92
|
+
1, 15, :_reduce_9,
|
93
|
+
2, 15, :_reduce_10,
|
94
|
+
1, 20, :_reduce_11,
|
95
|
+
2, 20, :_reduce_12,
|
96
|
+
3, 20, :_reduce_13,
|
97
|
+
2, 22, :_reduce_14,
|
98
|
+
3, 22, :_reduce_15,
|
99
|
+
2, 23, :_reduce_none,
|
100
|
+
3, 23, :_reduce_none,
|
101
|
+
2, 21, :_reduce_18,
|
102
|
+
2, 24, :_reduce_19,
|
103
|
+
1, 25, :_reduce_20,
|
104
|
+
2, 25, :_reduce_21,
|
105
|
+
3, 25, :_reduce_22,
|
106
|
+
2, 26, :_reduce_23,
|
107
|
+
1, 27, :_reduce_none,
|
108
|
+
1, 27, :_reduce_none,
|
109
|
+
1, 27, :_reduce_none,
|
110
|
+
1, 27, :_reduce_none,
|
111
|
+
1, 27, :_reduce_none,
|
112
|
+
1, 16, :_reduce_29,
|
113
|
+
2, 16, :_reduce_30,
|
114
|
+
4, 28, :_reduce_31,
|
115
|
+
6, 28, :_reduce_32,
|
116
|
+
1, 19, :_reduce_33,
|
117
|
+
2, 19, :_reduce_34 ]
|
118
|
+
|
119
|
+
racc_reduce_n = 35
|
120
|
+
|
121
|
+
racc_shift_n = 56
|
117
122
|
|
118
123
|
racc_token_table = {
|
119
124
|
false => 0,
|
@@ -168,7 +173,9 @@ Racc_token_to_s_table = [
|
|
168
173
|
"Root",
|
169
174
|
"Feature",
|
170
175
|
"Scenarios",
|
176
|
+
"FeatureTags",
|
171
177
|
"Newline",
|
178
|
+
"Tags",
|
172
179
|
"FeatureHeader",
|
173
180
|
"Background",
|
174
181
|
"FeatureName",
|
@@ -177,8 +184,7 @@ Racc_token_to_s_table = [
|
|
177
184
|
"Steps",
|
178
185
|
"Step",
|
179
186
|
"Keyword",
|
180
|
-
"Scenario"
|
181
|
-
"Tags" ]
|
187
|
+
"Scenario" ]
|
182
188
|
|
183
189
|
Racc_debug_parser = false
|
184
190
|
|
@@ -200,152 +206,180 @@ module_eval(<<'.,.,', 'gherkin.y', 17)
|
|
200
206
|
end
|
201
207
|
.,.,
|
202
208
|
|
203
|
-
|
209
|
+
module_eval(<<'.,.,', 'gherkin.y', 18)
|
210
|
+
def _reduce_3(val, _values, result)
|
211
|
+
result = val[1]; result.tags = val[0]
|
212
|
+
result
|
213
|
+
end
|
214
|
+
.,.,
|
215
|
+
|
216
|
+
module_eval(<<'.,.,', 'gherkin.y', 20)
|
217
|
+
def _reduce_4(val, _values, result)
|
218
|
+
result = val[1]; result.scenarios = val[2]; result.tags = val[0]
|
219
|
+
result
|
220
|
+
end
|
221
|
+
.,.,
|
222
|
+
|
223
|
+
# reduce 5 omitted
|
224
|
+
|
225
|
+
# reduce 6 omitted
|
226
|
+
|
227
|
+
module_eval(<<'.,.,', 'gherkin.y', 29)
|
228
|
+
def _reduce_7(val, _values, result)
|
229
|
+
result = val[0]
|
230
|
+
result
|
231
|
+
end
|
232
|
+
.,.,
|
204
233
|
|
205
|
-
|
234
|
+
module_eval(<<'.,.,', 'gherkin.y', 30)
|
235
|
+
def _reduce_8(val, _values, result)
|
236
|
+
result = val[1]
|
237
|
+
result
|
238
|
+
end
|
239
|
+
.,.,
|
206
240
|
|
207
|
-
module_eval(<<'.,.,', 'gherkin.y',
|
208
|
-
def
|
241
|
+
module_eval(<<'.,.,', 'gherkin.y', 33)
|
242
|
+
def _reduce_9(val, _values, result)
|
209
243
|
result = val[0]
|
210
244
|
result
|
211
245
|
end
|
212
246
|
.,.,
|
213
247
|
|
214
|
-
module_eval(<<'.,.,', 'gherkin.y',
|
215
|
-
def
|
248
|
+
module_eval(<<'.,.,', 'gherkin.y', 35)
|
249
|
+
def _reduce_10(val, _values, result)
|
216
250
|
result = val[0]; result.background = val[1]
|
217
251
|
result
|
218
252
|
end
|
219
253
|
.,.,
|
220
254
|
|
221
|
-
module_eval(<<'.,.,', 'gherkin.y',
|
222
|
-
def
|
255
|
+
module_eval(<<'.,.,', 'gherkin.y', 39)
|
256
|
+
def _reduce_11(val, _values, result)
|
223
257
|
result = val[0]
|
224
258
|
result
|
225
259
|
end
|
226
260
|
.,.,
|
227
261
|
|
228
|
-
module_eval(<<'.,.,', 'gherkin.y',
|
229
|
-
def
|
262
|
+
module_eval(<<'.,.,', 'gherkin.y', 40)
|
263
|
+
def _reduce_12(val, _values, result)
|
230
264
|
result = val[0]
|
231
265
|
result
|
232
266
|
end
|
233
267
|
.,.,
|
234
268
|
|
235
|
-
module_eval(<<'.,.,', 'gherkin.y',
|
236
|
-
def
|
269
|
+
module_eval(<<'.,.,', 'gherkin.y', 42)
|
270
|
+
def _reduce_13(val, _values, result)
|
237
271
|
result = val[0]
|
238
272
|
result
|
239
273
|
end
|
240
274
|
.,.,
|
241
275
|
|
242
|
-
module_eval(<<'.,.,', 'gherkin.y',
|
243
|
-
def
|
276
|
+
module_eval(<<'.,.,', 'gherkin.y', 46)
|
277
|
+
def _reduce_14(val, _values, result)
|
244
278
|
result = AST::Feature.new(val[1]); result.pos(filename, lineno)
|
245
279
|
result
|
246
280
|
end
|
247
281
|
.,.,
|
248
282
|
|
249
|
-
module_eval(<<'.,.,', 'gherkin.y',
|
250
|
-
def
|
283
|
+
module_eval(<<'.,.,', 'gherkin.y', 47)
|
284
|
+
def _reduce_15(val, _values, result)
|
251
285
|
result = AST::Feature.new(val[2]); result.pos(filename, lineno)
|
252
286
|
result
|
253
287
|
end
|
254
288
|
.,.,
|
255
289
|
|
256
|
-
# reduce
|
290
|
+
# reduce 16 omitted
|
257
291
|
|
258
|
-
# reduce
|
292
|
+
# reduce 17 omitted
|
259
293
|
|
260
|
-
module_eval(<<'.,.,', 'gherkin.y',
|
261
|
-
def
|
294
|
+
module_eval(<<'.,.,', 'gherkin.y', 57)
|
295
|
+
def _reduce_18(val, _values, result)
|
262
296
|
result = val[0]; result.steps = val[1]
|
263
297
|
result
|
264
298
|
end
|
265
299
|
.,.,
|
266
300
|
|
267
|
-
module_eval(<<'.,.,', 'gherkin.y',
|
268
|
-
def
|
301
|
+
module_eval(<<'.,.,', 'gherkin.y', 61)
|
302
|
+
def _reduce_19(val, _values, result)
|
269
303
|
result = AST::Background.new; result.pos(filename, lineno)
|
270
304
|
result
|
271
305
|
end
|
272
306
|
.,.,
|
273
307
|
|
274
|
-
module_eval(<<'.,.,', 'gherkin.y',
|
275
|
-
def
|
308
|
+
module_eval(<<'.,.,', 'gherkin.y', 65)
|
309
|
+
def _reduce_20(val, _values, result)
|
276
310
|
result = [val[0]]
|
277
311
|
result
|
278
312
|
end
|
279
313
|
.,.,
|
280
314
|
|
281
|
-
module_eval(<<'.,.,', 'gherkin.y',
|
282
|
-
def
|
283
|
-
result = val[0]
|
315
|
+
module_eval(<<'.,.,', 'gherkin.y', 66)
|
316
|
+
def _reduce_21(val, _values, result)
|
317
|
+
result = [val[0]]
|
284
318
|
result
|
285
319
|
end
|
286
320
|
.,.,
|
287
321
|
|
288
|
-
module_eval(<<'.,.,', 'gherkin.y',
|
289
|
-
def
|
322
|
+
module_eval(<<'.,.,', 'gherkin.y', 67)
|
323
|
+
def _reduce_22(val, _values, result)
|
324
|
+
val[2].unshift(val[0]); result = val[2]
|
325
|
+
result
|
326
|
+
end
|
327
|
+
.,.,
|
328
|
+
|
329
|
+
module_eval(<<'.,.,', 'gherkin.y', 71)
|
330
|
+
def _reduce_23(val, _values, result)
|
290
331
|
result = AST::Step.new(val[1], val[0]); result.pos(filename, lineno)
|
291
332
|
result
|
292
333
|
end
|
293
334
|
.,.,
|
294
335
|
|
295
|
-
# reduce
|
336
|
+
# reduce 24 omitted
|
296
337
|
|
297
|
-
# reduce
|
338
|
+
# reduce 25 omitted
|
298
339
|
|
299
|
-
# reduce
|
340
|
+
# reduce 26 omitted
|
300
341
|
|
301
|
-
# reduce
|
342
|
+
# reduce 27 omitted
|
302
343
|
|
303
|
-
# reduce
|
344
|
+
# reduce 28 omitted
|
304
345
|
|
305
|
-
module_eval(<<'.,.,', 'gherkin.y',
|
306
|
-
def
|
346
|
+
module_eval(<<'.,.,', 'gherkin.y', 79)
|
347
|
+
def _reduce_29(val, _values, result)
|
307
348
|
result = [val[0]]
|
308
349
|
result
|
309
350
|
end
|
310
351
|
.,.,
|
311
352
|
|
312
|
-
module_eval(<<'.,.,', 'gherkin.y',
|
313
|
-
def
|
353
|
+
module_eval(<<'.,.,', 'gherkin.y', 80)
|
354
|
+
def _reduce_30(val, _values, result)
|
314
355
|
result = val[0] << val[1]
|
315
356
|
result
|
316
357
|
end
|
317
358
|
.,.,
|
318
359
|
|
319
|
-
module_eval(<<'.,.,', 'gherkin.y',
|
320
|
-
def
|
321
|
-
result = val[0] << val[2]
|
322
|
-
result
|
323
|
-
end
|
324
|
-
.,.,
|
325
|
-
|
326
|
-
module_eval(<<'.,.,', 'gherkin.y', 78)
|
327
|
-
def _reduce_27(val, _values, result)
|
360
|
+
module_eval(<<'.,.,', 'gherkin.y', 85)
|
361
|
+
def _reduce_31(val, _values, result)
|
328
362
|
result = AST::Scenario.new(val[1], val[3]); result.pos(filename, lineno - 1)
|
329
363
|
result
|
330
364
|
end
|
331
365
|
.,.,
|
332
366
|
|
333
|
-
module_eval(<<'.,.,', 'gherkin.y',
|
334
|
-
def
|
367
|
+
module_eval(<<'.,.,', 'gherkin.y', 88)
|
368
|
+
def _reduce_32(val, _values, result)
|
335
369
|
result = AST::Scenario.new(val[3], val[5], val[0]); result.pos(filename, lineno - 2)
|
336
370
|
result
|
337
371
|
end
|
338
372
|
.,.,
|
339
373
|
|
340
|
-
module_eval(<<'.,.,', 'gherkin.y',
|
341
|
-
def
|
374
|
+
module_eval(<<'.,.,', 'gherkin.y', 92)
|
375
|
+
def _reduce_33(val, _values, result)
|
342
376
|
result = [AST::Tag.new(val[0])]
|
343
377
|
result
|
344
378
|
end
|
345
379
|
.,.,
|
346
380
|
|
347
|
-
module_eval(<<'.,.,', 'gherkin.y',
|
348
|
-
def
|
381
|
+
module_eval(<<'.,.,', 'gherkin.y', 93)
|
382
|
+
def _reduce_34(val, _values, result)
|
349
383
|
result = val[0] << AST::Tag.new(val[1])
|
350
384
|
result
|
351
385
|
end
|
data/lib/gherkin/version.rb
CHANGED
data/test/gherkin/ast_test.rb
CHANGED
@@ -42,39 +42,41 @@ module Gherkin
|
|
42
42
|
|
43
43
|
describe Feature do
|
44
44
|
it 'is Enumerable' do
|
45
|
+
tags = ['-foo', '-bar']
|
45
46
|
background = ['foo', 'bar']
|
46
47
|
elements = ['+foo', '+bar']
|
47
48
|
|
48
|
-
instance = Feature.new("My feature", elements, background )
|
49
|
+
instance = Feature.new("My feature", elements, tags, background )
|
50
|
+
instance.tags.each.to_a.must_equal ['-foo', '-bar']
|
49
51
|
instance.background.each.to_a.must_equal ['foo', 'bar']
|
50
52
|
instance.each.to_a.must_equal ['+foo', '+bar']
|
51
53
|
end
|
52
54
|
end
|
53
55
|
|
54
56
|
describe Scenario do
|
55
|
-
|
56
|
-
steps = [
|
57
|
+
before do
|
58
|
+
@steps = [
|
57
59
|
OpenStruct.new(line: 4),
|
58
60
|
OpenStruct.new(line: 5),
|
59
61
|
]
|
60
62
|
end
|
61
63
|
|
62
64
|
it 'is Enumerable' do
|
63
|
-
instance = Scenario.new("Name", steps)
|
64
|
-
instance.each.to_a.must_equal steps
|
65
|
+
instance = Scenario.new("Name", @steps)
|
66
|
+
instance.each.to_a.must_equal @steps
|
65
67
|
end
|
66
68
|
|
67
69
|
it 'has tags' do
|
68
70
|
tags = ['javascript', 'wip']
|
69
71
|
|
70
|
-
instance = Scenario.new("Name", steps, tags)
|
72
|
+
instance = Scenario.new("Name", @steps, tags)
|
71
73
|
instance.tags.must_equal tags
|
72
74
|
end
|
73
75
|
end
|
74
76
|
|
75
77
|
describe Background do
|
76
|
-
|
77
|
-
steps = [
|
78
|
+
before do
|
79
|
+
@steps = [
|
78
80
|
OpenStruct.new(line: 4),
|
79
81
|
OpenStruct.new(line: 5),
|
80
82
|
]
|
@@ -85,13 +87,13 @@ module Gherkin
|
|
85
87
|
end
|
86
88
|
|
87
89
|
it 'is Enumerable' do
|
88
|
-
instance = Background.new(steps)
|
89
|
-
instance.each.to_a.must_equal steps
|
90
|
+
instance = Background.new(@steps)
|
91
|
+
instance.each.to_a.must_equal @steps
|
90
92
|
end
|
91
93
|
|
92
94
|
describe 'when there are background steps' do
|
93
95
|
it 'records line' do
|
94
|
-
instance = Background.new(steps)
|
96
|
+
instance = Background.new(@steps)
|
95
97
|
instance.pos("file", 3)
|
96
98
|
instance.line.must_equal 3
|
97
99
|
end
|
@@ -2,22 +2,24 @@ require 'test_helper'
|
|
2
2
|
|
3
3
|
module Gherkin
|
4
4
|
describe Parser do
|
5
|
-
|
5
|
+
before do
|
6
|
+
@lexer = Parser.new
|
7
|
+
end
|
6
8
|
|
7
9
|
it 'ignores commments' do
|
8
|
-
lexer.tokenize("# this is a comment").must_equal []
|
10
|
+
@lexer.tokenize("# this is a comment").must_equal []
|
9
11
|
end
|
10
12
|
|
11
13
|
it 'parses newlines' do
|
12
|
-
lexer.tokenize("\n\n").must_equal [[:NEWLINE, "\n"], [:NEWLINE, "\n"]]
|
14
|
+
@lexer.tokenize("\n\n").must_equal [[:NEWLINE, "\n"], [:NEWLINE, "\n"]]
|
13
15
|
end
|
14
16
|
|
15
17
|
it 'parses text and strips it' do
|
16
|
-
lexer.tokenize(" Arbitrary text ").must_equal [[:TEXT, "Arbitrary text"]]
|
18
|
+
@lexer.tokenize(" Arbitrary text ").must_equal [[:TEXT, "Arbitrary text"]]
|
17
19
|
end
|
18
20
|
|
19
21
|
it 'parses tags' do
|
20
|
-
lexer.tokenize("@javascript @wip").must_equal [
|
22
|
+
@lexer.tokenize("@javascript @wip").must_equal [
|
21
23
|
[:TAG, "javascript"],
|
22
24
|
[:TAG, "wip"],
|
23
25
|
]
|
@@ -27,7 +29,7 @@ module Gherkin
|
|
27
29
|
%w(Feature: Background: Scenario:).each do |keyword|
|
28
30
|
it "parses #{keyword}:" do
|
29
31
|
name = keyword[0..-2]
|
30
|
-
lexer.tokenize(keyword).must_equal [[name.upcase.to_sym, name]]
|
32
|
+
@lexer.tokenize(keyword).must_equal [[name.upcase.to_sym, name]]
|
31
33
|
end
|
32
34
|
end
|
33
35
|
end
|
@@ -35,7 +37,7 @@ module Gherkin
|
|
35
37
|
describe 'Step keywords' do
|
36
38
|
%w(Given When Then And But).each do |keyword|
|
37
39
|
it "parses #{keyword}" do
|
38
|
-
lexer.tokenize(keyword).must_equal [[keyword.upcase.to_sym, keyword]]
|
40
|
+
@lexer.tokenize(keyword).must_equal [[keyword.upcase.to_sym, keyword]]
|
39
41
|
end
|
40
42
|
end
|
41
43
|
end
|
@@ -24,6 +24,24 @@ module Gherkin
|
|
24
24
|
feature.name.must_equal "my feature"
|
25
25
|
end
|
26
26
|
|
27
|
+
it 'parses feature with tags' do
|
28
|
+
feature = parse("""
|
29
|
+
@wip @with-dash
|
30
|
+
Feature: Do something
|
31
|
+
""")
|
32
|
+
feature.name.must_equal "Do something"
|
33
|
+
feature.tags.first.name.must_equal "wip"
|
34
|
+
feature.tags.last.name.must_equal "with-dash"
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'parses feature with tagsi event without newline at start' do
|
38
|
+
feature = parse(
|
39
|
+
"@wip\nFeature: Do something"
|
40
|
+
)
|
41
|
+
feature.name.must_equal "Do something"
|
42
|
+
feature.tags.first.name.must_equal "wip"
|
43
|
+
end
|
44
|
+
|
27
45
|
it 'parses feature with background' do
|
28
46
|
feature = parse("""
|
29
47
|
Feature: Do something
|
@@ -71,6 +89,23 @@ Feature: Do something
|
|
71
89
|
last_scenario.steps.last.name.must_equal "something else"
|
72
90
|
end
|
73
91
|
|
92
|
+
it 'parses feature with no ending newline' do
|
93
|
+
feature = parse(%(
|
94
|
+
Feature: Do something
|
95
|
+
|
96
|
+
Scenario: Foo bar baz
|
97
|
+
Given blah foo bar
|
98
|
+
Then something else))
|
99
|
+
scenarios = feature.scenarios
|
100
|
+
scenarios.size.must_equal 1
|
101
|
+
|
102
|
+
first_scenario = scenarios.first
|
103
|
+
|
104
|
+
first_scenario.name.must_equal "Foo bar baz"
|
105
|
+
first_scenario.steps.first.name.must_equal "blah foo bar"
|
106
|
+
first_scenario.steps.last.name.must_equal "something else"
|
107
|
+
end
|
108
|
+
|
74
109
|
it 'parses feature with scenarios with tags' do
|
75
110
|
feature = parse("""
|
76
111
|
Feature: Do something
|
@@ -79,7 +114,7 @@ Feature: Do something
|
|
79
114
|
Given blah foo bar
|
80
115
|
Then something else
|
81
116
|
|
82
|
-
@javascript @wip
|
117
|
+
@javascript @wip @with-vcr
|
83
118
|
Scenario: Foo bar baz blah
|
84
119
|
Given blah foo bar
|
85
120
|
Then something else
|
@@ -88,8 +123,9 @@ Feature: Do something
|
|
88
123
|
|
89
124
|
last_scenario = scenarios.last
|
90
125
|
|
91
|
-
last_scenario.tags.
|
92
|
-
last_scenario.tags.
|
126
|
+
last_scenario.tags[0].name.must_equal "javascript"
|
127
|
+
last_scenario.tags[1].name.must_equal "wip"
|
128
|
+
last_scenario.tags[2].name.must_equal "with-vcr"
|
93
129
|
end
|
94
130
|
end
|
95
131
|
end
|
metadata
CHANGED
@@ -1,78 +1,75 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: gherkin-ruby
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.0
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 1
|
9
|
-
- 0
|
10
|
-
version: 0.1.0
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Marc Divins
|
14
9
|
- Josep M. Bach
|
15
10
|
autorequire:
|
16
11
|
bindir: bin
|
17
12
|
cert_chain: []
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
dependencies:
|
22
|
-
- !ruby/object:Gem::Dependency
|
13
|
+
date: 2012-05-21 00:00:00.000000000 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
23
16
|
name: rexical
|
24
|
-
|
25
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
26
18
|
none: false
|
27
|
-
requirements:
|
28
|
-
- -
|
29
|
-
- !ruby/object:Gem::Version
|
30
|
-
|
31
|
-
segments:
|
32
|
-
- 0
|
33
|
-
version: "0"
|
19
|
+
requirements:
|
20
|
+
- - ! '>='
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '0'
|
34
23
|
type: :runtime
|
35
|
-
version_requirements: *id001
|
36
|
-
- !ruby/object:Gem::Dependency
|
37
|
-
name: racc
|
38
24
|
prerelease: false
|
39
|
-
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
26
|
none: false
|
41
|
-
requirements:
|
42
|
-
- -
|
43
|
-
- !ruby/object:Gem::Version
|
44
|
-
|
45
|
-
|
46
|
-
- 0
|
47
|
-
version: "0"
|
48
|
-
type: :runtime
|
49
|
-
version_requirements: *id002
|
50
|
-
- !ruby/object:Gem::Dependency
|
27
|
+
requirements:
|
28
|
+
- - ! '>='
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
version: '0'
|
31
|
+
- !ruby/object:Gem::Dependency
|
51
32
|
name: minitest
|
33
|
+
requirement: !ruby/object:Gem::Requirement
|
34
|
+
none: false
|
35
|
+
requirements:
|
36
|
+
- - ! '>='
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '0'
|
39
|
+
type: :development
|
52
40
|
prerelease: false
|
53
|
-
|
41
|
+
version_requirements: !ruby/object:Gem::Requirement
|
54
42
|
none: false
|
55
|
-
requirements:
|
56
|
-
- -
|
57
|
-
- !ruby/object:Gem::Version
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
43
|
+
requirements:
|
44
|
+
- - ! '>='
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: racc
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
62
55
|
type: :development
|
63
|
-
|
64
|
-
|
65
|
-
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: !ruby/object:Gem::Requirement
|
58
|
+
none: false
|
59
|
+
requirements:
|
60
|
+
- - ! '>='
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
63
|
+
description: Gherkin-ruby is a Gherkin parser in pure Ruby using Rexical and Racc
|
64
|
+
email:
|
66
65
|
- marcdivc@gmail.com
|
67
66
|
- josep.m.bach@gmail.com
|
68
67
|
executables: []
|
69
|
-
|
70
68
|
extensions: []
|
71
|
-
|
72
69
|
extra_rdoc_files: []
|
73
|
-
|
74
|
-
files:
|
70
|
+
files:
|
75
71
|
- .gitignore
|
72
|
+
- .rvmrc
|
76
73
|
- .travis.yml
|
77
74
|
- Gemfile
|
78
75
|
- Rakefile
|
@@ -91,41 +88,31 @@ files:
|
|
91
88
|
- test/gherkin/parser/parser_test.rb
|
92
89
|
- test/gherkin/parser_test.rb
|
93
90
|
- test/test_helper.rb
|
94
|
-
|
95
|
-
homepage: http://github.com/codegram/gherkin
|
91
|
+
homepage: http://github.com/codegram/gherkin-ruby
|
96
92
|
licenses: []
|
97
|
-
|
98
93
|
post_install_message:
|
99
94
|
rdoc_options: []
|
100
|
-
|
101
|
-
require_paths:
|
95
|
+
require_paths:
|
102
96
|
- lib
|
103
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
97
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
104
98
|
none: false
|
105
|
-
requirements:
|
106
|
-
- -
|
107
|
-
- !ruby/object:Gem::Version
|
108
|
-
|
109
|
-
|
110
|
-
- 0
|
111
|
-
version: "0"
|
112
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - ! '>='
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
103
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
113
104
|
none: false
|
114
|
-
requirements:
|
115
|
-
- -
|
116
|
-
- !ruby/object:Gem::Version
|
117
|
-
|
118
|
-
segments:
|
119
|
-
- 0
|
120
|
-
version: "0"
|
105
|
+
requirements:
|
106
|
+
- - ! '>='
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: '0'
|
121
109
|
requirements: []
|
122
|
-
|
123
110
|
rubyforge_project: gherkin-ruby
|
124
|
-
rubygems_version: 1.
|
111
|
+
rubygems_version: 1.8.21
|
125
112
|
signing_key:
|
126
113
|
specification_version: 3
|
127
|
-
summary: Gherkin-ruby is a Gherkin parser in pure Ruby using
|
128
|
-
test_files:
|
114
|
+
summary: Gherkin-ruby is a Gherkin parser in pure Ruby using Rexical and Racc
|
115
|
+
test_files:
|
129
116
|
- test/gherkin/ast_test.rb
|
130
117
|
- test/gherkin/parser/lexer_test.rb
|
131
118
|
- test/gherkin/parser/parser_test.rb
|