gherkin 2.0.2-i386-mswin32 → 2.1.0-i386-mswin32
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +12 -0
- data/LICENSE +1 -1
- data/README.rdoc +2 -2
- data/Rakefile +2 -2
- data/VERSION.yml +2 -2
- data/features/json_formatter.feature +3 -41
- data/features/step_definitions/gherkin_steps.rb +5 -6
- data/features/step_definitions/json_formatter_steps.rb +3 -2
- data/features/step_definitions/json_lexer_steps.rb +5 -5
- data/features/step_definitions/pretty_formatter_steps.rb +9 -13
- data/features/support/env.rb +1 -1
- data/lib/gherkin/formatter/argument.rb +1 -0
- data/lib/gherkin/formatter/filter_formatter.rb +149 -0
- data/lib/gherkin/formatter/json_formatter.rb +35 -45
- data/lib/gherkin/formatter/line_filter.rb +26 -0
- data/lib/gherkin/formatter/model.rb +85 -0
- data/lib/gherkin/formatter/pretty_formatter.rb +36 -39
- data/lib/gherkin/formatter/regexp_filter.rb +17 -0
- data/lib/gherkin/formatter/tag_count_formatter.rb +44 -0
- data/lib/gherkin/i18n.rb +5 -5
- data/lib/gherkin/i18n.yml +13 -0
- data/lib/gherkin/i18n_lexer.rb +2 -2
- data/lib/gherkin/{json_lexer.rb → json_parser.rb} +17 -5
- data/lib/gherkin/{parser → listener}/event.rb +1 -1
- data/lib/gherkin/{parser → listener}/formatter_listener.rb +30 -23
- data/lib/gherkin/native/java.rb +9 -1
- data/lib/gherkin/parser/parser.rb +27 -14
- data/lib/gherkin/rubify.rb +5 -1
- data/lib/gherkin/tag_expression.rb +62 -0
- data/lib/gherkin/tools/files.rb +3 -4
- data/lib/gherkin/tools/reformat.rb +2 -2
- data/lib/gherkin/tools/stats.rb +3 -4
- data/lib/gherkin/tools/stats_listener.rb +1 -1
- data/ragel/lexer.c.rl.erb +2 -3
- data/ragel/lexer.java.rl.erb +1 -2
- data/ragel/lexer.rb.rl.erb +1 -2
- data/spec/gherkin/fixtures/complex_for_filtering.feature +60 -0
- data/spec/gherkin/fixtures/complex_with_tags.feature +61 -0
- data/spec/gherkin/fixtures/hantu_pisang.feature +35 -0
- data/spec/gherkin/formatter/filter_formatter_spec.rb +156 -0
- data/spec/gherkin/formatter/model_spec.rb +15 -0
- data/spec/gherkin/formatter/pretty_formatter_spec.rb +17 -16
- data/spec/gherkin/formatter/tag_count_formatter_spec.rb +31 -0
- data/spec/gherkin/i18n_lexer_spec.rb +3 -3
- data/spec/gherkin/i18n_spec.rb +2 -4
- data/spec/gherkin/{json_lexer_spec.rb → json_parser_spec.rb} +13 -8
- data/spec/gherkin/sexp_recorder.rb +10 -4
- data/spec/gherkin/shared/lexer_group.rb +0 -40
- data/spec/gherkin/shared/py_string_group.rb +0 -1
- data/spec/gherkin/shared/row_group.rb +1 -2
- data/spec/gherkin/tag_expression_spec.rb +137 -0
- data/spec/spec_helper.rb +5 -1
- data/tasks/bench.rake +5 -9
- metadata +33 -25
- data/lib/gherkin/parser/filter_listener.rb +0 -203
- data/lib/gherkin/parser/row.rb +0 -15
- data/lib/gherkin/parser/tag_expression.rb +0 -50
- data/spec/gherkin/parser/filter_listener_spec.rb +0 -397
- data/spec/gherkin/parser/formatter_listener_spec.rb +0 -134
- data/spec/gherkin/parser/parser_spec.rb +0 -50
- data/spec/gherkin/parser/tag_expression_spec.rb +0 -116
@@ -5,7 +5,7 @@ module Gherkin
|
|
5
5
|
module Lexer
|
6
6
|
shared_examples_for "a Gherkin lexer lexing rows" do
|
7
7
|
def scan(gherkin)
|
8
|
-
@lexer.scan(gherkin
|
8
|
+
@lexer.scan(gherkin)
|
9
9
|
end
|
10
10
|
|
11
11
|
rows = {
|
@@ -43,7 +43,6 @@ module Gherkin
|
|
43
43
|
it "should allow utf-8" do
|
44
44
|
scan(" | ůﻚ | 2 | \n")
|
45
45
|
@listener.to_sexp.should == [
|
46
|
-
[:location, 'test.feature', 0],
|
47
46
|
[:row, ["ůﻚ", "2"], 1],
|
48
47
|
[:eof]
|
49
48
|
]
|
@@ -0,0 +1,137 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'gherkin/tag_expression'
|
3
|
+
|
4
|
+
module Gherkin
|
5
|
+
describe TagExpression do
|
6
|
+
context "no tags" do
|
7
|
+
before(:each) do
|
8
|
+
@e = Gherkin::TagExpression.new([])
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should match @foo" do
|
12
|
+
@e.eval(['@foo']).should == true
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should match empty tags" do
|
16
|
+
@e.eval([]).should == true
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
context "@foo" do
|
21
|
+
before(:each) do
|
22
|
+
@e = Gherkin::TagExpression.new(['@foo'])
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should match @foo" do
|
26
|
+
@e.eval(['@foo']).should == true
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should not match @bar" do
|
30
|
+
@e.eval(['@bar']).should == false
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should not match no tags" do
|
34
|
+
@e.eval([]).should == false
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
context "!@foo" do
|
39
|
+
before(:each) do
|
40
|
+
@e = Gherkin::TagExpression.new(['~@foo'])
|
41
|
+
end
|
42
|
+
|
43
|
+
it "should match @bar" do
|
44
|
+
@e.eval(['@bar']).should == true
|
45
|
+
end
|
46
|
+
|
47
|
+
it "should not match @foo" do
|
48
|
+
@e.eval(['@foo']).should == false
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
context "@foo || @bar" do
|
53
|
+
before(:each) do
|
54
|
+
@e = Gherkin::TagExpression.new(['@foo,@bar'])
|
55
|
+
end
|
56
|
+
|
57
|
+
it "should match @foo" do
|
58
|
+
@e.eval(['@foo']).should == true
|
59
|
+
end
|
60
|
+
|
61
|
+
it "should match @bar" do
|
62
|
+
@e.eval(['@bar']).should == true
|
63
|
+
end
|
64
|
+
|
65
|
+
it "should not match @zap" do
|
66
|
+
@e.eval(['@zap']).should == false
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
context "(@foo || @bar) && !@zap" do
|
71
|
+
before(:each) do
|
72
|
+
@e = Gherkin::TagExpression.new(['@foo,@bar', '~@zap'])
|
73
|
+
end
|
74
|
+
|
75
|
+
it "should match @foo" do
|
76
|
+
@e.eval(['@foo']).should == true
|
77
|
+
end
|
78
|
+
|
79
|
+
it "should not match @foo @zap" do
|
80
|
+
@e.eval(['@foo', '@zap']).should == false
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
context "(@foo:3 || !@bar:4) && @zap:5" do
|
85
|
+
before(:each) do
|
86
|
+
@e = Gherkin::TagExpression.new(['@foo:3,~@bar','@zap:5'])
|
87
|
+
end
|
88
|
+
|
89
|
+
it "should count tags for positive tags" do
|
90
|
+
rubify_hash(@e.limits).should == {'@foo' => 3, '@zap' => 5}
|
91
|
+
end
|
92
|
+
|
93
|
+
it "should match @foo @zap" do
|
94
|
+
@e.eval(['@foo', '@zap']).should == true
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
context "Parsing '@foo:3,~@bar', '@zap:5'" do
|
99
|
+
before(:each) do
|
100
|
+
@e = Gherkin::TagExpression.new([' @foo:3 , ~@bar ', ' @zap:5 '])
|
101
|
+
end
|
102
|
+
|
103
|
+
unless defined?(JRUBY_VERSION)
|
104
|
+
it "should split and trim (ruby implementation detail)" do
|
105
|
+
@e.__send__(:ruby_expression).should == "(!vars['@bar']||vars['@foo'])&&(vars['@zap'])"
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
it "should have limits" do
|
110
|
+
rubify_hash(@e.limits).should == {"@zap"=>5, "@foo"=>3}
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
context "Tag limits" do
|
115
|
+
it "should be counted for negative tags" do
|
116
|
+
@e = Gherkin::TagExpression.new(['~@todo:3'])
|
117
|
+
rubify_hash(@e.limits).should == {"@todo"=>3}
|
118
|
+
end
|
119
|
+
|
120
|
+
it "should be counted for positive tags" do
|
121
|
+
@e = Gherkin::TagExpression.new(['@todo:3'])
|
122
|
+
rubify_hash(@e.limits).should == {"@todo"=>3}
|
123
|
+
end
|
124
|
+
|
125
|
+
it "should raise an error for inconsistent limits" do
|
126
|
+
lambda do
|
127
|
+
@e = Gherkin::TagExpression.new(['@todo:3', '~@todo:4'])
|
128
|
+
end.should raise_error(/Inconsistent tag limits for @todo: 3 and 4/)
|
129
|
+
end
|
130
|
+
|
131
|
+
it "should allow duplicate consistent limits" do
|
132
|
+
@e = Gherkin::TagExpression.new(['@todo:3', '~@todo:3'])
|
133
|
+
rubify_hash(@e.limits).should == {"@todo"=>3}
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -11,7 +11,11 @@ require 'gherkin/shared/row_group'
|
|
11
11
|
|
12
12
|
module GherkinSpecHelper
|
13
13
|
def scan_file(file)
|
14
|
-
@lexer.scan(
|
14
|
+
@lexer.scan(fixture(file))
|
15
|
+
end
|
16
|
+
|
17
|
+
def fixture(file)
|
18
|
+
File.new(File.dirname(__FILE__) + "/gherkin/fixtures/" + file).read
|
15
19
|
end
|
16
20
|
|
17
21
|
def rubify_hash(hash)
|
data/tasks/bench.rake
CHANGED
@@ -106,23 +106,19 @@ class Benchmarker
|
|
106
106
|
|
107
107
|
def run_rb_gherkin
|
108
108
|
require 'gherkin'
|
109
|
-
require '
|
110
|
-
|
111
|
-
parser = Gherkin::Parser::Parser.new(NullListener.new, true, "root")
|
112
|
-
lexer = Gherkin::I18nLexer.new(parser, true)
|
109
|
+
require 'null_formatter'
|
110
|
+
parser = Gherkin::Parser::Parser.new(NullFormatter.new, true, "root", true)
|
113
111
|
@features.each do |feature|
|
114
|
-
|
112
|
+
parser.parse(File.read(feature), feature, 0)
|
115
113
|
end
|
116
114
|
end
|
117
115
|
|
118
116
|
def run_native_gherkin
|
119
117
|
require 'gherkin'
|
120
|
-
require 'gherkin/i18n_lexer'
|
121
118
|
require 'null_listener'
|
122
|
-
parser = Gherkin::Parser::Parser.new(
|
123
|
-
lexer = Gherkin::I18nLexer.new(parser, false)
|
119
|
+
parser = Gherkin::Parser::Parser.new(NullFormatter.new, true, "root", false)
|
124
120
|
@features.each do |feature|
|
125
|
-
|
121
|
+
parser.parse(File.read(feature), feature, 0)
|
126
122
|
end
|
127
123
|
end
|
128
124
|
|
metadata
CHANGED
@@ -5,9 +5,9 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 2
|
8
|
+
- 1
|
8
9
|
- 0
|
9
|
-
|
10
|
-
version: 2.0.2
|
10
|
+
version: 2.1.0
|
11
11
|
platform: i386-mswin32
|
12
12
|
authors:
|
13
13
|
- Mike Sassak
|
@@ -17,7 +17,7 @@ autorequire:
|
|
17
17
|
bindir: bin
|
18
18
|
cert_chain: []
|
19
19
|
|
20
|
-
date: 2010-
|
20
|
+
date: 2010-07-12 00:00:00 +02:00
|
21
21
|
default_executable: gherkin
|
22
22
|
dependencies:
|
23
23
|
- !ruby/object:Gem::Dependency
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - ~>
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
hash:
|
47
|
+
hash: 62196477
|
48
48
|
segments:
|
49
49
|
- 2
|
50
50
|
- 0
|
51
51
|
- 0
|
52
52
|
- beta
|
53
|
-
-
|
54
|
-
version: 2.0.0.beta.
|
53
|
+
- 15
|
54
|
+
version: 2.0.0.beta.15
|
55
55
|
type: :development
|
56
56
|
version_requirements: *id002
|
57
57
|
- !ruby/object:Gem::Dependency
|
@@ -62,12 +62,12 @@ dependencies:
|
|
62
62
|
requirements:
|
63
63
|
- - ~>
|
64
64
|
- !ruby/object:Gem::Version
|
65
|
-
hash:
|
65
|
+
hash: 55
|
66
66
|
segments:
|
67
67
|
- 0
|
68
68
|
- 8
|
69
|
-
-
|
70
|
-
version: 0.8.
|
69
|
+
- 4
|
70
|
+
version: 0.8.4
|
71
71
|
type: :development
|
72
72
|
version_requirements: *id003
|
73
73
|
- !ruby/object:Gem::Dependency
|
@@ -136,6 +136,7 @@ files:
|
|
136
136
|
- lib/1.8/gherkin_lexer_en.so
|
137
137
|
- lib/1.8/gherkin_lexer_en_au.so
|
138
138
|
- lib/1.8/gherkin_lexer_en_lol.so
|
139
|
+
- lib/1.8/gherkin_lexer_en_pirate.so
|
139
140
|
- lib/1.8/gherkin_lexer_en_scouse.so
|
140
141
|
- lib/1.8/gherkin_lexer_en_tx.so
|
141
142
|
- lib/1.8/gherkin_lexer_eo.so
|
@@ -180,6 +181,7 @@ files:
|
|
180
181
|
- lib/1.9/gherkin_lexer_en.so
|
181
182
|
- lib/1.9/gherkin_lexer_en_au.so
|
182
183
|
- lib/1.9/gherkin_lexer_en_lol.so
|
184
|
+
- lib/1.9/gherkin_lexer_en_pirate.so
|
183
185
|
- lib/1.9/gherkin_lexer_en_scouse.so
|
184
186
|
- lib/1.9/gherkin_lexer_en_tx.so
|
185
187
|
- lib/1.9/gherkin_lexer_eo.so
|
@@ -220,30 +222,33 @@ files:
|
|
220
222
|
- lib/gherkin/formatter/argument.rb
|
221
223
|
- lib/gherkin/formatter/colors.rb
|
222
224
|
- lib/gherkin/formatter/escaping.rb
|
225
|
+
- lib/gherkin/formatter/filter_formatter.rb
|
223
226
|
- lib/gherkin/formatter/json_formatter.rb
|
227
|
+
- lib/gherkin/formatter/line_filter.rb
|
228
|
+
- lib/gherkin/formatter/model.rb
|
224
229
|
- lib/gherkin/formatter/monochrome_format.rb
|
225
230
|
- lib/gherkin/formatter/pretty_formatter.rb
|
231
|
+
- lib/gherkin/formatter/regexp_filter.rb
|
232
|
+
- lib/gherkin/formatter/tag_count_formatter.rb
|
226
233
|
- lib/gherkin/i18n.rb
|
227
234
|
- lib/gherkin/i18n.yml
|
228
235
|
- lib/gherkin/i18n_lexer.rb
|
229
|
-
- lib/gherkin/
|
236
|
+
- lib/gherkin/json_parser.rb
|
237
|
+
- lib/gherkin/listener/event.rb
|
238
|
+
- lib/gherkin/listener/formatter_listener.rb
|
230
239
|
- lib/gherkin/native.rb
|
231
240
|
- lib/gherkin/native/ikvm.rb
|
232
241
|
- lib/gherkin/native/java.rb
|
233
242
|
- lib/gherkin/native/null.rb
|
234
|
-
- lib/gherkin/parser/event.rb
|
235
|
-
- lib/gherkin/parser/filter_listener.rb
|
236
|
-
- lib/gherkin/parser/formatter_listener.rb
|
237
243
|
- lib/gherkin/parser/meta.txt
|
238
244
|
- lib/gherkin/parser/parser.rb
|
239
245
|
- lib/gherkin/parser/root.txt
|
240
|
-
- lib/gherkin/parser/row.rb
|
241
246
|
- lib/gherkin/parser/steps.txt
|
242
|
-
- lib/gherkin/parser/tag_expression.rb
|
243
247
|
- lib/gherkin/rb_lexer.rb
|
244
248
|
- lib/gherkin/rb_lexer/.gitignore
|
245
249
|
- lib/gherkin/rb_lexer/README.rdoc
|
246
250
|
- lib/gherkin/rubify.rb
|
251
|
+
- lib/gherkin/tag_expression.rb
|
247
252
|
- lib/gherkin/tools.rb
|
248
253
|
- lib/gherkin/tools/files.rb
|
249
254
|
- lib/gherkin/tools/reformat.rb
|
@@ -259,7 +264,10 @@ files:
|
|
259
264
|
- spec/gherkin/fixtures/comments_in_table.feature
|
260
265
|
- spec/gherkin/fixtures/complex.feature
|
261
266
|
- spec/gherkin/fixtures/complex.json
|
267
|
+
- spec/gherkin/fixtures/complex_for_filtering.feature
|
268
|
+
- spec/gherkin/fixtures/complex_with_tags.feature
|
262
269
|
- spec/gherkin/fixtures/dos_line_endings.feature
|
270
|
+
- spec/gherkin/fixtures/hantu_pisang.feature
|
263
271
|
- spec/gherkin/fixtures/i18n_fr.feature
|
264
272
|
- spec/gherkin/fixtures/i18n_no.feature
|
265
273
|
- spec/gherkin/fixtures/i18n_zh-CN.feature
|
@@ -268,24 +276,24 @@ files:
|
|
268
276
|
- spec/gherkin/fixtures/with_bom.feature
|
269
277
|
- spec/gherkin/formatter/argument_spec.rb
|
270
278
|
- spec/gherkin/formatter/colors_spec.rb
|
279
|
+
- spec/gherkin/formatter/filter_formatter_spec.rb
|
280
|
+
- spec/gherkin/formatter/model_spec.rb
|
271
281
|
- spec/gherkin/formatter/pretty_formatter_spec.rb
|
272
282
|
- spec/gherkin/formatter/spaces.feature
|
273
283
|
- spec/gherkin/formatter/tabs.feature
|
284
|
+
- spec/gherkin/formatter/tag_count_formatter_spec.rb
|
274
285
|
- spec/gherkin/i18n_lexer_spec.rb
|
275
286
|
- spec/gherkin/i18n_spec.rb
|
276
287
|
- spec/gherkin/java_lexer_spec.rb
|
277
|
-
- spec/gherkin/
|
288
|
+
- spec/gherkin/json_parser_spec.rb
|
278
289
|
- spec/gherkin/output_stream_string_io.rb
|
279
|
-
- spec/gherkin/parser/filter_listener_spec.rb
|
280
|
-
- spec/gherkin/parser/formatter_listener_spec.rb
|
281
|
-
- spec/gherkin/parser/parser_spec.rb
|
282
|
-
- spec/gherkin/parser/tag_expression_spec.rb
|
283
290
|
- spec/gherkin/rb_lexer_spec.rb
|
284
291
|
- spec/gherkin/sexp_recorder.rb
|
285
292
|
- spec/gherkin/shared/lexer_group.rb
|
286
293
|
- spec/gherkin/shared/py_string_group.rb
|
287
294
|
- spec/gherkin/shared/row_group.rb
|
288
295
|
- spec/gherkin/shared/tags_group.rb
|
296
|
+
- spec/gherkin/tag_expression_spec.rb
|
289
297
|
- spec/spec_helper.rb
|
290
298
|
- tasks/bench.rake
|
291
299
|
- tasks/bench/feature_builder.rb
|
@@ -337,20 +345,20 @@ test_files:
|
|
337
345
|
- spec/gherkin/c_lexer_spec.rb
|
338
346
|
- spec/gherkin/formatter/argument_spec.rb
|
339
347
|
- spec/gherkin/formatter/colors_spec.rb
|
348
|
+
- spec/gherkin/formatter/filter_formatter_spec.rb
|
349
|
+
- spec/gherkin/formatter/model_spec.rb
|
340
350
|
- spec/gherkin/formatter/pretty_formatter_spec.rb
|
351
|
+
- spec/gherkin/formatter/tag_count_formatter_spec.rb
|
341
352
|
- spec/gherkin/i18n_lexer_spec.rb
|
342
353
|
- spec/gherkin/i18n_spec.rb
|
343
354
|
- spec/gherkin/java_lexer_spec.rb
|
344
|
-
- spec/gherkin/
|
355
|
+
- spec/gherkin/json_parser_spec.rb
|
345
356
|
- spec/gherkin/output_stream_string_io.rb
|
346
|
-
- spec/gherkin/parser/filter_listener_spec.rb
|
347
|
-
- spec/gherkin/parser/formatter_listener_spec.rb
|
348
|
-
- spec/gherkin/parser/parser_spec.rb
|
349
|
-
- spec/gherkin/parser/tag_expression_spec.rb
|
350
357
|
- spec/gherkin/rb_lexer_spec.rb
|
351
358
|
- spec/gherkin/sexp_recorder.rb
|
352
359
|
- spec/gherkin/shared/lexer_group.rb
|
353
360
|
- spec/gherkin/shared/py_string_group.rb
|
354
361
|
- spec/gherkin/shared/row_group.rb
|
355
362
|
- spec/gherkin/shared/tags_group.rb
|
363
|
+
- spec/gherkin/tag_expression_spec.rb
|
356
364
|
- spec/spec_helper.rb
|
@@ -1,203 +0,0 @@
|
|
1
|
-
require 'gherkin/parser/event'
|
2
|
-
require 'gherkin/parser/tag_expression'
|
3
|
-
require 'gherkin/native'
|
4
|
-
|
5
|
-
module Gherkin
|
6
|
-
module Parser
|
7
|
-
# This class filters events based on filter criteria.
|
8
|
-
class FilterListener
|
9
|
-
native_impl('gherkin')
|
10
|
-
|
11
|
-
# Creates a new instance that replays events to +listener+, filtered by +filters+,
|
12
|
-
# an Array that can contain one of the following:
|
13
|
-
#
|
14
|
-
# * Line numbers (Fixnum) to filter on.
|
15
|
-
# * Name regexen (Regexp) to filter on. Matches against :feature, :background, :scenario, :scenario_outline and :examples
|
16
|
-
# * Tag expressions (String) to filter on.
|
17
|
-
#
|
18
|
-
def initialize(listener, filters)
|
19
|
-
@listener = listener
|
20
|
-
@filter_method = detect_filter(filters)
|
21
|
-
|
22
|
-
@meta_buffer = []
|
23
|
-
@feature_buffer = []
|
24
|
-
@scenario_buffer = []
|
25
|
-
@examples_buffer = []
|
26
|
-
@examples_rows_buffer = []
|
27
|
-
|
28
|
-
@feature_tags = []
|
29
|
-
@scenario_tags = []
|
30
|
-
@example_tags = []
|
31
|
-
|
32
|
-
@table_state = :step
|
33
|
-
end
|
34
|
-
|
35
|
-
def location(uri, offset)
|
36
|
-
@listener.location(uri, offset)
|
37
|
-
end
|
38
|
-
|
39
|
-
private
|
40
|
-
|
41
|
-
def method_missing(*event_args)
|
42
|
-
event = Event.new(event_args)
|
43
|
-
|
44
|
-
return event.replay(@listener) if no_filters?
|
45
|
-
|
46
|
-
case(event.event)
|
47
|
-
when :tag
|
48
|
-
@meta_buffer << event
|
49
|
-
when :comment
|
50
|
-
@meta_buffer << event
|
51
|
-
when :feature
|
52
|
-
@feature_buffer = @meta_buffer
|
53
|
-
@feature_buffer << event
|
54
|
-
@feature_tags = extract_tags
|
55
|
-
@meta_buffer = []
|
56
|
-
@feature_ok = true if filter_match?(event)
|
57
|
-
when :background
|
58
|
-
@feature_buffer += @meta_buffer
|
59
|
-
@feature_buffer << event
|
60
|
-
@meta_buffer = []
|
61
|
-
@table_state = :background
|
62
|
-
@background_ok = true if filter_match?(event)
|
63
|
-
when :scenario
|
64
|
-
replay_examples_rows_buffer
|
65
|
-
@scenario_buffer = @meta_buffer
|
66
|
-
@scenario_buffer << event
|
67
|
-
@scenario_tags = extract_tags
|
68
|
-
@example_tags = []
|
69
|
-
@meta_buffer = []
|
70
|
-
@scenario_ok = filter_match?(*@scenario_buffer) || tag_match?
|
71
|
-
@examples_ok = false
|
72
|
-
@background_ok = false
|
73
|
-
@table_state = :step
|
74
|
-
when :scenario_outline
|
75
|
-
replay_examples_rows_buffer
|
76
|
-
@scenario_buffer = @meta_buffer
|
77
|
-
@scenario_buffer << event
|
78
|
-
@scenario_tags = extract_tags
|
79
|
-
@example_tags = []
|
80
|
-
@meta_buffer = []
|
81
|
-
@scenario_ok = filter_match?(*@scenario_buffer)
|
82
|
-
@examples_ok = false
|
83
|
-
@background_ok = false
|
84
|
-
@table_state = :step
|
85
|
-
when :examples
|
86
|
-
replay_examples_rows_buffer
|
87
|
-
@examples_buffer = @meta_buffer
|
88
|
-
@examples_buffer << event
|
89
|
-
@example_tags = extract_tags
|
90
|
-
@meta_buffer = []
|
91
|
-
@examples_rows_buffer = []
|
92
|
-
@examples_ok = filter_match?(*@examples_buffer) || tag_match?
|
93
|
-
@table_state = :examples
|
94
|
-
when :step
|
95
|
-
case(@table_state)
|
96
|
-
when :background
|
97
|
-
@feature_buffer += @meta_buffer
|
98
|
-
@feature_buffer << event
|
99
|
-
@meta_buffer = []
|
100
|
-
@background_ok = true if filter_match?(event)
|
101
|
-
else
|
102
|
-
@scenario_buffer << event
|
103
|
-
@scenario_ok ||= filter_match?(*@scenario_buffer)
|
104
|
-
@table_state = :step
|
105
|
-
end
|
106
|
-
when :row
|
107
|
-
case(@table_state)
|
108
|
-
when :examples
|
109
|
-
unless header_row_already_buffered?
|
110
|
-
@examples_buffer << event
|
111
|
-
@examples_ok = true if filter_match?(*@examples_buffer)
|
112
|
-
else
|
113
|
-
@examples_rows_buffer << event if @scenario_ok || @examples_ok || @feature_ok || filter_match?(event)
|
114
|
-
end
|
115
|
-
when :step
|
116
|
-
@scenario_buffer << event
|
117
|
-
@scenario_ok ||= filter_match?(*@scenario_buffer)
|
118
|
-
when :background
|
119
|
-
@feature_buffer += @meta_buffer
|
120
|
-
@feature_buffer << event
|
121
|
-
@meta_buffer = []
|
122
|
-
else
|
123
|
-
raise "Bad table_state:#{@table_state.inspect}"
|
124
|
-
end
|
125
|
-
when :py_string
|
126
|
-
if @table_state == :background
|
127
|
-
@feature_buffer << event
|
128
|
-
@feature_ok ||= filter_match?(*@feature_buffer)
|
129
|
-
else
|
130
|
-
@scenario_buffer << event
|
131
|
-
@scenario_ok ||= filter_match?(*@scenario_buffer)
|
132
|
-
end
|
133
|
-
when :eof
|
134
|
-
replay_examples_rows_buffer
|
135
|
-
event.replay(@listener)
|
136
|
-
return
|
137
|
-
else
|
138
|
-
super
|
139
|
-
end
|
140
|
-
|
141
|
-
if @scenario_ok || @examples_ok || @feature_ok || @background_ok
|
142
|
-
replay_buffers
|
143
|
-
end
|
144
|
-
end
|
145
|
-
|
146
|
-
def detect_filter(filters)
|
147
|
-
@filters = filters
|
148
|
-
raise "Bad filter: #{filters.inspect}" if filters.map{|filter| filter.class}.uniq.length > 1
|
149
|
-
@filter_method = case(filters[0])
|
150
|
-
when Fixnum
|
151
|
-
:line_match?
|
152
|
-
when Regexp
|
153
|
-
:name_match?
|
154
|
-
when String
|
155
|
-
TagExpression.new(filters)
|
156
|
-
end
|
157
|
-
end
|
158
|
-
|
159
|
-
def no_filters?
|
160
|
-
@filters.empty?
|
161
|
-
end
|
162
|
-
|
163
|
-
def header_row_already_buffered?
|
164
|
-
return @examples_buffer.any? && @examples_buffer[-1].event == :row
|
165
|
-
end
|
166
|
-
|
167
|
-
def filter_match?(*events)
|
168
|
-
return false unless[:name_match?, :line_match?].include?(@filter_method)
|
169
|
-
events.detect{|event| event.__send__(@filter_method, @filters)}
|
170
|
-
end
|
171
|
-
|
172
|
-
def tag_match?
|
173
|
-
return TagExpression === @filter_method && @filter_method.eval(current_tags)
|
174
|
-
end
|
175
|
-
|
176
|
-
def replay_buffers
|
177
|
-
(@feature_buffer + @scenario_buffer).each do |event|
|
178
|
-
event.replay(@listener)
|
179
|
-
end
|
180
|
-
@feature_buffer = []
|
181
|
-
@scenario_buffer = []
|
182
|
-
end
|
183
|
-
|
184
|
-
def replay_examples_rows_buffer
|
185
|
-
if @examples_rows_buffer.any?
|
186
|
-
replay_buffers
|
187
|
-
(@examples_buffer + @examples_rows_buffer).each do |event|
|
188
|
-
event.replay(@listener)
|
189
|
-
end
|
190
|
-
@examples_rows_buffer = []
|
191
|
-
end
|
192
|
-
end
|
193
|
-
|
194
|
-
def current_tags
|
195
|
-
@feature_tags + @scenario_tags + @example_tags
|
196
|
-
end
|
197
|
-
|
198
|
-
def extract_tags
|
199
|
-
@meta_buffer.select { |event| event.event == :tag }.map { |event| event.keyword }
|
200
|
-
end
|
201
|
-
end
|
202
|
-
end
|
203
|
-
end
|