gherkin 2.0.2-java → 2.1.0-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. data/History.txt +12 -0
  2. data/LICENSE +1 -1
  3. data/README.rdoc +2 -2
  4. data/Rakefile +2 -2
  5. data/VERSION.yml +2 -2
  6. data/features/json_formatter.feature +3 -41
  7. data/features/step_definitions/gherkin_steps.rb +5 -6
  8. data/features/step_definitions/json_formatter_steps.rb +3 -2
  9. data/features/step_definitions/json_lexer_steps.rb +5 -5
  10. data/features/step_definitions/pretty_formatter_steps.rb +9 -13
  11. data/features/support/env.rb +1 -1
  12. data/lib/gherkin/formatter/argument.rb +1 -0
  13. data/lib/gherkin/formatter/filter_formatter.rb +149 -0
  14. data/lib/gherkin/formatter/json_formatter.rb +35 -45
  15. data/lib/gherkin/formatter/line_filter.rb +26 -0
  16. data/lib/gherkin/formatter/model.rb +85 -0
  17. data/lib/gherkin/formatter/pretty_formatter.rb +36 -39
  18. data/lib/gherkin/formatter/regexp_filter.rb +17 -0
  19. data/lib/gherkin/formatter/tag_count_formatter.rb +44 -0
  20. data/lib/gherkin/i18n.rb +5 -5
  21. data/lib/gherkin/i18n.yml +13 -0
  22. data/lib/gherkin/i18n_lexer.rb +2 -2
  23. data/lib/gherkin/{json_lexer.rb → json_parser.rb} +17 -5
  24. data/lib/gherkin/{parser → listener}/event.rb +1 -1
  25. data/lib/gherkin/{parser → listener}/formatter_listener.rb +30 -23
  26. data/lib/gherkin/native/java.rb +9 -1
  27. data/lib/gherkin/parser/parser.rb +27 -14
  28. data/lib/gherkin/rubify.rb +5 -1
  29. data/lib/gherkin/tag_expression.rb +62 -0
  30. data/lib/gherkin/tools/files.rb +3 -4
  31. data/lib/gherkin/tools/reformat.rb +2 -2
  32. data/lib/gherkin/tools/stats.rb +3 -4
  33. data/lib/gherkin/tools/stats_listener.rb +1 -1
  34. data/ragel/lexer.c.rl.erb +2 -3
  35. data/ragel/lexer.java.rl.erb +1 -2
  36. data/ragel/lexer.rb.rl.erb +1 -2
  37. data/spec/gherkin/fixtures/complex_for_filtering.feature +60 -0
  38. data/spec/gherkin/fixtures/complex_with_tags.feature +61 -0
  39. data/spec/gherkin/fixtures/hantu_pisang.feature +35 -0
  40. data/spec/gherkin/formatter/filter_formatter_spec.rb +156 -0
  41. data/spec/gherkin/formatter/model_spec.rb +15 -0
  42. data/spec/gherkin/formatter/pretty_formatter_spec.rb +17 -16
  43. data/spec/gherkin/formatter/tag_count_formatter_spec.rb +31 -0
  44. data/spec/gherkin/i18n_lexer_spec.rb +3 -3
  45. data/spec/gherkin/i18n_spec.rb +2 -4
  46. data/spec/gherkin/{json_lexer_spec.rb → json_parser_spec.rb} +13 -8
  47. data/spec/gherkin/sexp_recorder.rb +10 -4
  48. data/spec/gherkin/shared/lexer_group.rb +0 -40
  49. data/spec/gherkin/shared/py_string_group.rb +0 -1
  50. data/spec/gherkin/shared/row_group.rb +1 -2
  51. data/spec/gherkin/tag_expression_spec.rb +137 -0
  52. data/spec/spec_helper.rb +5 -1
  53. data/tasks/bench.rake +5 -9
  54. metadata +29 -24
  55. data/lib/gherkin/parser/filter_listener.rb +0 -203
  56. data/lib/gherkin/parser/row.rb +0 -15
  57. data/lib/gherkin/parser/tag_expression.rb +0 -50
  58. data/spec/gherkin/parser/filter_listener_spec.rb +0 -397
  59. data/spec/gherkin/parser/formatter_listener_spec.rb +0 -134
  60. data/spec/gherkin/parser/parser_spec.rb +0 -50
  61. data/spec/gherkin/parser/tag_expression_spec.rb +0 -116
@@ -52,7 +52,6 @@ EOS
52
52
  it "should parse content separated by two newlines" do
53
53
  scan ps("A\n\nB")
54
54
  @listener.to_sexp.should == [
55
- [:location, 'test.feature', 0],
56
55
  [:py_string, "A\n\nB", 1],
57
56
  [:eof]
58
57
  ]
@@ -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, "test.feature", 0)
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
@@ -11,7 +11,11 @@ require 'gherkin/shared/row_group'
11
11
 
12
12
  module GherkinSpecHelper
13
13
  def scan_file(file)
14
- @lexer.scan(File.new(File.dirname(__FILE__) + "/gherkin/fixtures/" + file).read, file, 0)
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)
@@ -106,23 +106,19 @@ class Benchmarker
106
106
 
107
107
  def run_rb_gherkin
108
108
  require 'gherkin'
109
- require 'gherkin/i18n_lexer'
110
- require 'null_listener'
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
- lexer.scan(File.read(feature), feature, 0)
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(NullListener.new, true, "root")
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
- lexer.scan(File.read(feature), feature, 0)
121
+ parser.parse(File.read(feature), feature, 0)
126
122
  end
127
123
  end
128
124
 
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 2
7
+ - 1
7
8
  - 0
8
- - 2
9
- version: 2.0.2
9
+ version: 2.1.0
10
10
  platform: java
11
11
  authors:
12
12
  - Mike Sassak
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2010-06-16 00:00:00 +02:00
19
+ date: 2010-07-12 00:00:00 +02:00
20
20
  default_executable: gherkin
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
@@ -45,8 +45,8 @@ dependencies:
45
45
  - 0
46
46
  - 0
47
47
  - beta
48
- - 11
49
- version: 2.0.0.beta.11
48
+ - 15
49
+ version: 2.0.0.beta.15
50
50
  type: :development
51
51
  version_requirements: *id002
52
52
  - !ruby/object:Gem::Dependency
@@ -59,8 +59,8 @@ dependencies:
59
59
  segments:
60
60
  - 0
61
61
  - 8
62
- - 1
63
- version: 0.8.1
62
+ - 4
63
+ version: 0.8.4
64
64
  type: :development
65
65
  version_requirements: *id003
66
66
  description: A fast Gherkin lexer/parser based on the Ragel State Machine Compiler.
@@ -103,37 +103,39 @@ files:
103
103
  - java/src/main/java/gherkin/lexer/.gitignore
104
104
  - java/src/main/resources/gherkin/.gitignore
105
105
  - lib/.gitignore
106
- - lib/gherkin.jar
107
106
  - lib/gherkin.rb
108
107
  - lib/gherkin/c_lexer.rb
109
108
  - lib/gherkin/cli/main.rb
110
109
  - lib/gherkin/formatter/argument.rb
111
110
  - lib/gherkin/formatter/colors.rb
112
111
  - lib/gherkin/formatter/escaping.rb
112
+ - lib/gherkin/formatter/filter_formatter.rb
113
113
  - lib/gherkin/formatter/json_formatter.rb
114
+ - lib/gherkin/formatter/line_filter.rb
115
+ - lib/gherkin/formatter/model.rb
114
116
  - lib/gherkin/formatter/monochrome_format.rb
115
117
  - lib/gherkin/formatter/pretty_formatter.rb
118
+ - lib/gherkin/formatter/regexp_filter.rb
119
+ - lib/gherkin/formatter/tag_count_formatter.rb
116
120
  - lib/gherkin/i18n.rb
117
121
  - lib/gherkin/i18n.yml
118
122
  - lib/gherkin/i18n_lexer.rb
119
- - lib/gherkin/json_lexer.rb
123
+ - lib/gherkin/json_parser.rb
124
+ - lib/gherkin/listener/event.rb
125
+ - lib/gherkin/listener/formatter_listener.rb
120
126
  - lib/gherkin/native.rb
121
127
  - lib/gherkin/native/ikvm.rb
122
128
  - lib/gherkin/native/java.rb
123
129
  - lib/gherkin/native/null.rb
124
- - lib/gherkin/parser/event.rb
125
- - lib/gherkin/parser/filter_listener.rb
126
- - lib/gherkin/parser/formatter_listener.rb
127
130
  - lib/gherkin/parser/meta.txt
128
131
  - lib/gherkin/parser/parser.rb
129
132
  - lib/gherkin/parser/root.txt
130
- - lib/gherkin/parser/row.rb
131
133
  - lib/gherkin/parser/steps.txt
132
- - lib/gherkin/parser/tag_expression.rb
133
134
  - lib/gherkin/rb_lexer.rb
134
135
  - lib/gherkin/rb_lexer/.gitignore
135
136
  - lib/gherkin/rb_lexer/README.rdoc
136
137
  - lib/gherkin/rubify.rb
138
+ - lib/gherkin/tag_expression.rb
137
139
  - lib/gherkin/tools.rb
138
140
  - lib/gherkin/tools/files.rb
139
141
  - lib/gherkin/tools/reformat.rb
@@ -149,7 +151,10 @@ files:
149
151
  - spec/gherkin/fixtures/comments_in_table.feature
150
152
  - spec/gherkin/fixtures/complex.feature
151
153
  - spec/gherkin/fixtures/complex.json
154
+ - spec/gherkin/fixtures/complex_for_filtering.feature
155
+ - spec/gherkin/fixtures/complex_with_tags.feature
152
156
  - spec/gherkin/fixtures/dos_line_endings.feature
157
+ - spec/gherkin/fixtures/hantu_pisang.feature
153
158
  - spec/gherkin/fixtures/i18n_fr.feature
154
159
  - spec/gherkin/fixtures/i18n_no.feature
155
160
  - spec/gherkin/fixtures/i18n_zh-CN.feature
@@ -158,24 +163,24 @@ files:
158
163
  - spec/gherkin/fixtures/with_bom.feature
159
164
  - spec/gherkin/formatter/argument_spec.rb
160
165
  - spec/gherkin/formatter/colors_spec.rb
166
+ - spec/gherkin/formatter/filter_formatter_spec.rb
167
+ - spec/gherkin/formatter/model_spec.rb
161
168
  - spec/gherkin/formatter/pretty_formatter_spec.rb
162
169
  - spec/gherkin/formatter/spaces.feature
163
170
  - spec/gherkin/formatter/tabs.feature
171
+ - spec/gherkin/formatter/tag_count_formatter_spec.rb
164
172
  - spec/gherkin/i18n_lexer_spec.rb
165
173
  - spec/gherkin/i18n_spec.rb
166
174
  - spec/gherkin/java_lexer_spec.rb
167
- - spec/gherkin/json_lexer_spec.rb
175
+ - spec/gherkin/json_parser_spec.rb
168
176
  - spec/gherkin/output_stream_string_io.rb
169
- - spec/gherkin/parser/filter_listener_spec.rb
170
- - spec/gherkin/parser/formatter_listener_spec.rb
171
- - spec/gherkin/parser/parser_spec.rb
172
- - spec/gherkin/parser/tag_expression_spec.rb
173
177
  - spec/gherkin/rb_lexer_spec.rb
174
178
  - spec/gherkin/sexp_recorder.rb
175
179
  - spec/gherkin/shared/lexer_group.rb
176
180
  - spec/gherkin/shared/py_string_group.rb
177
181
  - spec/gherkin/shared/row_group.rb
178
182
  - spec/gherkin/shared/tags_group.rb
183
+ - spec/gherkin/tag_expression_spec.rb
179
184
  - spec/spec_helper.rb
180
185
  - tasks/bench.rake
181
186
  - tasks/bench/feature_builder.rb
@@ -225,17 +230,17 @@ test_files:
225
230
  - spec/gherkin/i18n_lexer_spec.rb
226
231
  - spec/gherkin/i18n_spec.rb
227
232
  - spec/gherkin/java_lexer_spec.rb
228
- - spec/gherkin/json_lexer_spec.rb
233
+ - spec/gherkin/json_parser_spec.rb
229
234
  - spec/gherkin/output_stream_string_io.rb
230
235
  - spec/gherkin/rb_lexer_spec.rb
231
236
  - spec/gherkin/sexp_recorder.rb
237
+ - spec/gherkin/tag_expression_spec.rb
232
238
  - spec/gherkin/formatter/argument_spec.rb
233
239
  - spec/gherkin/formatter/colors_spec.rb
240
+ - spec/gherkin/formatter/filter_formatter_spec.rb
241
+ - spec/gherkin/formatter/model_spec.rb
234
242
  - spec/gherkin/formatter/pretty_formatter_spec.rb
235
- - spec/gherkin/parser/filter_listener_spec.rb
236
- - spec/gherkin/parser/formatter_listener_spec.rb
237
- - spec/gherkin/parser/parser_spec.rb
238
- - spec/gherkin/parser/tag_expression_spec.rb
243
+ - spec/gherkin/formatter/tag_count_formatter_spec.rb
239
244
  - spec/gherkin/shared/lexer_group.rb
240
245
  - spec/gherkin/shared/py_string_group.rb
241
246
  - spec/gherkin/shared/row_group.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