gherkin 2.5.4-x86-mingw32 → 2.6.0-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (112) hide show
  1. data/Gemfile +2 -0
  2. data/Gemfile.lock +9 -7
  3. data/History.md +11 -1
  4. data/README.md +1 -1
  5. data/features/json_formatter.feature +376 -310
  6. data/features/json_parser.feature +245 -228
  7. data/features/step_definitions/json_formatter_steps.rb +7 -4
  8. data/features/step_definitions/json_parser_steps.rb +1 -1
  9. data/features/step_definitions/pretty_formatter_steps.rb +2 -1
  10. data/gherkin.gemspec +4 -3
  11. data/lib/1.8/gherkin_lexer_ar.so +0 -0
  12. data/lib/1.8/gherkin_lexer_bg.so +0 -0
  13. data/lib/1.8/gherkin_lexer_ca.so +0 -0
  14. data/lib/1.8/gherkin_lexer_cs.so +0 -0
  15. data/lib/1.8/gherkin_lexer_cy_gb.so +0 -0
  16. data/lib/1.8/gherkin_lexer_da.so +0 -0
  17. data/lib/1.8/gherkin_lexer_de.so +0 -0
  18. data/lib/1.8/gherkin_lexer_en.so +0 -0
  19. data/lib/1.8/gherkin_lexer_en_au.so +0 -0
  20. data/lib/1.8/gherkin_lexer_en_lol.so +0 -0
  21. data/lib/1.8/gherkin_lexer_en_pirate.so +0 -0
  22. data/lib/1.8/gherkin_lexer_en_scouse.so +0 -0
  23. data/lib/1.8/gherkin_lexer_en_tx.so +0 -0
  24. data/lib/1.8/gherkin_lexer_eo.so +0 -0
  25. data/lib/1.8/gherkin_lexer_es.so +0 -0
  26. data/lib/1.8/gherkin_lexer_et.so +0 -0
  27. data/lib/1.8/gherkin_lexer_fi.so +0 -0
  28. data/lib/1.8/gherkin_lexer_fr.so +0 -0
  29. data/lib/1.8/gherkin_lexer_he.so +0 -0
  30. data/lib/1.8/gherkin_lexer_hr.so +0 -0
  31. data/lib/1.8/gherkin_lexer_hu.so +0 -0
  32. data/lib/1.8/gherkin_lexer_id.so +0 -0
  33. data/lib/1.8/gherkin_lexer_is.so +0 -0
  34. data/lib/1.8/gherkin_lexer_it.so +0 -0
  35. data/lib/1.8/gherkin_lexer_ja.so +0 -0
  36. data/lib/1.8/gherkin_lexer_ko.so +0 -0
  37. data/lib/1.8/gherkin_lexer_lt.so +0 -0
  38. data/lib/1.8/gherkin_lexer_lu.so +0 -0
  39. data/lib/1.8/gherkin_lexer_lv.so +0 -0
  40. data/lib/1.8/gherkin_lexer_nl.so +0 -0
  41. data/lib/1.8/gherkin_lexer_no.so +0 -0
  42. data/lib/1.8/gherkin_lexer_pl.so +0 -0
  43. data/lib/1.8/gherkin_lexer_pt.so +0 -0
  44. data/lib/1.8/gherkin_lexer_ro.so +0 -0
  45. data/lib/1.8/gherkin_lexer_ru.so +0 -0
  46. data/lib/1.8/gherkin_lexer_sk.so +0 -0
  47. data/lib/1.8/gherkin_lexer_sr_cyrl.so +0 -0
  48. data/lib/1.8/gherkin_lexer_sr_latn.so +0 -0
  49. data/lib/1.8/gherkin_lexer_sv.so +0 -0
  50. data/lib/1.8/gherkin_lexer_tr.so +0 -0
  51. data/lib/1.8/gherkin_lexer_uk.so +0 -0
  52. data/lib/1.8/gherkin_lexer_uz.so +0 -0
  53. data/lib/1.8/gherkin_lexer_vi.so +0 -0
  54. data/lib/1.8/gherkin_lexer_zh_cn.so +0 -0
  55. data/lib/1.8/gherkin_lexer_zh_tw.so +0 -0
  56. data/lib/1.9/gherkin_lexer_ar.so +0 -0
  57. data/lib/1.9/gherkin_lexer_bg.so +0 -0
  58. data/lib/1.9/gherkin_lexer_ca.so +0 -0
  59. data/lib/1.9/gherkin_lexer_cs.so +0 -0
  60. data/lib/1.9/gherkin_lexer_cy_gb.so +0 -0
  61. data/lib/1.9/gherkin_lexer_da.so +0 -0
  62. data/lib/1.9/gherkin_lexer_de.so +0 -0
  63. data/lib/1.9/gherkin_lexer_en.so +0 -0
  64. data/lib/1.9/gherkin_lexer_en_au.so +0 -0
  65. data/lib/1.9/gherkin_lexer_en_lol.so +0 -0
  66. data/lib/1.9/gherkin_lexer_en_pirate.so +0 -0
  67. data/lib/1.9/gherkin_lexer_en_scouse.so +0 -0
  68. data/lib/1.9/gherkin_lexer_en_tx.so +0 -0
  69. data/lib/1.9/gherkin_lexer_eo.so +0 -0
  70. data/lib/1.9/gherkin_lexer_es.so +0 -0
  71. data/lib/1.9/gherkin_lexer_et.so +0 -0
  72. data/lib/1.9/gherkin_lexer_fi.so +0 -0
  73. data/lib/1.9/gherkin_lexer_fr.so +0 -0
  74. data/lib/1.9/gherkin_lexer_he.so +0 -0
  75. data/lib/1.9/gherkin_lexer_hr.so +0 -0
  76. data/lib/1.9/gherkin_lexer_hu.so +0 -0
  77. data/lib/1.9/gherkin_lexer_id.so +0 -0
  78. data/lib/1.9/gherkin_lexer_is.so +0 -0
  79. data/lib/1.9/gherkin_lexer_it.so +0 -0
  80. data/lib/1.9/gherkin_lexer_ja.so +0 -0
  81. data/lib/1.9/gherkin_lexer_ko.so +0 -0
  82. data/lib/1.9/gherkin_lexer_lt.so +0 -0
  83. data/lib/1.9/gherkin_lexer_lu.so +0 -0
  84. data/lib/1.9/gherkin_lexer_lv.so +0 -0
  85. data/lib/1.9/gherkin_lexer_nl.so +0 -0
  86. data/lib/1.9/gherkin_lexer_no.so +0 -0
  87. data/lib/1.9/gherkin_lexer_pl.so +0 -0
  88. data/lib/1.9/gherkin_lexer_pt.so +0 -0
  89. data/lib/1.9/gherkin_lexer_ro.so +0 -0
  90. data/lib/1.9/gherkin_lexer_ru.so +0 -0
  91. data/lib/1.9/gherkin_lexer_sk.so +0 -0
  92. data/lib/1.9/gherkin_lexer_sr_cyrl.so +0 -0
  93. data/lib/1.9/gherkin_lexer_sr_latn.so +0 -0
  94. data/lib/1.9/gherkin_lexer_sv.so +0 -0
  95. data/lib/1.9/gherkin_lexer_tr.so +0 -0
  96. data/lib/1.9/gherkin_lexer_uk.so +0 -0
  97. data/lib/1.9/gherkin_lexer_uz.so +0 -0
  98. data/lib/1.9/gherkin_lexer_vi.so +0 -0
  99. data/lib/1.9/gherkin_lexer_zh_cn.so +0 -0
  100. data/lib/1.9/gherkin_lexer_zh_tw.so +0 -0
  101. data/lib/gherkin/formatter/json_formatter.rb +13 -9
  102. data/lib/gherkin/formatter/model.rb +78 -20
  103. data/lib/gherkin/formatter/pretty_formatter.rb +1 -1
  104. data/lib/gherkin/json_parser.rb +32 -24
  105. data/lib/gherkin/listener/formatter_listener.rb +76 -50
  106. data/spec/gherkin/fixtures/complex.json +8 -1
  107. data/spec/gherkin/formatter/json_formatter_spec.rb +49 -43
  108. data/spec/gherkin/formatter/model_spec.rb +2 -2
  109. data/spec/gherkin/formatter/pretty_formatter_spec.rb +10 -10
  110. data/spec/gherkin/json_parser_spec.rb +93 -77
  111. data/spec/gherkin/sexp_recorder.rb +0 -3
  112. metadata +25 -25
@@ -11,15 +11,18 @@ class Hash
11
11
  end
12
12
 
13
13
  Given /^a JSON formatter$/ do
14
- @io = StringIO.new
15
- @formatter = Gherkin::Formatter::JSONFormatter.new(@io)
14
+ @out = StringIO.new
15
+ @formatter = Gherkin::Formatter::JSONFormatter.new(@out)
16
16
  end
17
17
 
18
18
  Then /^the outputted JSON should be:$/ do |expected_json|
19
19
  require 'json'
20
- puts JSON.pretty_generate(JSON.parse(@io.string))
20
+ @formatter.close
21
+ actual_json = @out.string
22
+ puts actual_json
23
+ puts JSON.pretty_generate(JSON.parse(actual_json))
21
24
  expected = JSON.parse(expected_json)
22
- actual = JSON.parse(@io.string)
25
+ actual = JSON.parse(actual_json)
23
26
  actual.should == expected
24
27
  end
25
28
 
@@ -12,7 +12,7 @@ Given /^a JSON lexer$/ do
12
12
  end
13
13
 
14
14
  Given /^the following JSON is parsed:$/ do |text|
15
- @json_parser.parse(JSON.pretty_generate(JSON.parse(text)), "unknown.json", 0)
15
+ @json_parser.parse(JSON.pretty_generate(JSON.parse(text)))
16
16
  end
17
17
 
18
18
  Then /^the outputted text should be:$/ do |expected_text|
@@ -20,11 +20,12 @@ module PrettyPlease
20
20
  json_formatter = Gherkin::Formatter::JSONFormatter.new(json)
21
21
  gherkin_parser = Gherkin::Parser::Parser.new(json_formatter, true)
22
22
  parse(gherkin_parser, gherkin, feature_path)
23
+ json_formatter.close
23
24
 
24
25
  io = StringIO.new
25
26
  pretty_formatter = Gherkin::Formatter::PrettyFormatter.new(io, true, false)
26
27
  json_parser = Gherkin::JSONParser.new(pretty_formatter, pretty_formatter)
27
- json_parser.parse(json.string, "#{feature_path}.json", 0)
28
+ json_parser.parse(json.string)
28
29
 
29
30
  io.string
30
31
  end
@@ -2,7 +2,8 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "gherkin"
5
- s.version = "2.5.4"
5
+ # If bumping the major version here, comment out the cucumber dependency below and uncomment in the Gemfile to build against a local cucumber.
6
+ s.version = "2.6.0"
6
7
  s.authors = ["Mike Sassak", "Gregory Hnatiuk", "Aslak Hellesøy"]
7
8
  s.description = "A fast Gherkin lexer/parser based on the Ragel State Machine Compiler."
8
9
  s.summary = "#{s.name}-#{s.version}"
@@ -45,10 +46,10 @@ Gem::Specification.new do |s|
45
46
 
46
47
  s.add_runtime_dependency('json', '>= 1.4.6')
47
48
 
48
- s.add_development_dependency('cucumber', '>= 1.1.0')
49
+ s.add_development_dependency('cucumber', '>= 1.1.1')
49
50
  s.add_development_dependency('rake', '>= 0.9.2')
50
51
  s.add_development_dependency('bundler', '>= 1.0.21')
51
- s.add_development_dependency('rspec', '>= 2.6.0')
52
+ s.add_development_dependency('rspec', '>= 2.7.0')
52
53
 
53
54
  unless ENV['RUBY_CC_VERSION'] || defined?(JRUBY_VERSION)
54
55
  s.add_development_dependency('therubyracer', '>= 0.9.8') if ENV['GHERKIN_JS']
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -5,26 +5,31 @@ require 'base64'
5
5
 
6
6
  module Gherkin
7
7
  module Formatter
8
+ # This class doesn't really generate JSON - instead it populates an Array that can easily
9
+ # be turned into JSON.
8
10
  class JSONFormatter
9
11
  native_impl('gherkin')
10
12
 
11
13
  include Base64
12
- attr_reader :gherkin_object
13
14
 
14
- # Creates a new instance that writes the resulting JSON to +io+.
15
- # If +io+ is nil, the JSON will not be written, but instead a Ruby
16
- # object can be retrieved with #gherkin_object
17
15
  def initialize(io)
16
+ raise "Must be writeable" unless io.respond_to?(:write)
18
17
  @io = io
18
+ @feature_hashes = []
19
+ end
20
+
21
+ def close
22
+ @io.write(@feature_hashes.to_json)
19
23
  end
20
24
 
21
25
  def uri(uri)
22
- # We're ignoring the uri - we don't want it as part of the JSON
23
- # (The pretty formatter uses it just for visual niceness - comments)
26
+ @uri = uri
24
27
  end
25
28
 
26
29
  def feature(feature)
27
- @gherkin_object = feature.to_hash
30
+ @feature_hash = feature.to_hash
31
+ @feature_hash['uri'] = @uri
32
+ @feature_hashes << @feature_hash
28
33
  end
29
34
 
30
35
  def background(background)
@@ -68,13 +73,12 @@ module Gherkin
68
73
  end
69
74
 
70
75
  def eof
71
- @io.write(@gherkin_object.to_json) if @io
72
76
  end
73
77
 
74
78
  private
75
79
 
76
80
  def feature_elements
77
- @gherkin_object['elements'] ||= []
81
+ @feature_hash['elements'] ||= []
78
82
  end
79
83
 
80
84
  def feature_element
@@ -31,11 +31,12 @@ module Gherkin
31
31
  end
32
32
 
33
33
  class TagStatement < DescribedStatement
34
- attr_reader :tags
34
+ attr_reader :tags, :id
35
35
 
36
- def initialize(comments, tags, keyword, name, description, line)
36
+ def initialize(comments, tags, keyword, name, description, line, id)
37
37
  super(comments, keyword, name, description, line)
38
38
  @tags = tags
39
+ @id = id
39
40
  end
40
41
 
41
42
  def first_non_comment_line
@@ -46,10 +47,6 @@ module Gherkin
46
47
  class Feature < TagStatement
47
48
  native_impl('gherkin')
48
49
 
49
- def initialize(comments, tags, keyword, name, description, line)
50
- super(comments, tags, keyword, name, description, line)
51
- end
52
-
53
50
  def replay(formatter)
54
51
  formatter.feature(self)
55
52
  end
@@ -71,8 +68,8 @@ module Gherkin
71
68
  class Scenario < TagStatement
72
69
  native_impl('gherkin')
73
70
 
74
- def initialize(comments, tags, keyword, name, description, line)
75
- super(comments, tags, keyword, name, description, line)
71
+ def initialize(comments, tags, keyword, name, description, line, id)
72
+ super(comments, tags, keyword, name, description, line, id)
76
73
  @type = "scenario"
77
74
  end
78
75
 
@@ -84,8 +81,8 @@ module Gherkin
84
81
  class ScenarioOutline < TagStatement
85
82
  native_impl('gherkin')
86
83
 
87
- def initialize(comments, tags, keyword, name, description, line)
88
- super(comments, tags, keyword, name, description, line)
84
+ def initialize(comments, tags, keyword, name, description, line, id)
85
+ super(comments, tags, keyword, name, description, line, id)
89
86
  @type = "scenario_outline"
90
87
  end
91
88
 
@@ -97,23 +94,47 @@ module Gherkin
97
94
  class Examples < TagStatement
98
95
  native_impl('gherkin')
99
96
 
100
- attr_accessor :rows
97
+ attr_accessor :rows # needs to remain mutable for filters
101
98
 
102
- def initialize(comments, tags, keyword, name, description, line, rows)
103
- super(comments, tags, keyword, name, description, line)
99
+ def initialize(comments, tags, keyword, name, description, line, id, rows)
100
+ super(comments, tags, keyword, name, description, line, id)
104
101
  @rows = rows
105
102
  end
106
103
 
107
104
  def replay(formatter)
108
105
  formatter.examples(self)
109
106
  end
107
+
108
+ class Builder
109
+ def initialize(*args)
110
+ @args = *args
111
+ @rows = nil
112
+ end
113
+
114
+ def row(comments, cells, line, id)
115
+ @rows ||= []
116
+ @rows << ExamplesTableRow.new(comments, cells, line, id)
117
+ end
118
+
119
+ def replay(formatter)
120
+ build.replay(formatter)
121
+ end
122
+
123
+ def build
124
+ Examples.new(*(@args << @rows))
125
+ end
126
+ end
110
127
  end
111
128
 
112
129
  class Step < BasicStatement
113
130
  native_impl('gherkin')
114
131
 
115
- attr_accessor :rows
116
- attr_accessor :doc_string
132
+ attr_reader :rows, :doc_string
133
+
134
+ def initialize(comments, keyword, name, line, rows, doc_string)
135
+ super(comments, keyword, name, line)
136
+ @rows, @doc_string = rows, doc_string
137
+ end
117
138
 
118
139
  def line_range
119
140
  range = super
@@ -136,6 +157,31 @@ module Gherkin
136
157
  Argument.new(offset, val)
137
158
  end
138
159
  end
160
+
161
+ class Builder
162
+ def initialize(*args)
163
+ @args = *args
164
+ @rows = nil
165
+ @doc_string = nil
166
+ end
167
+
168
+ def row(comments, cells, line, id)
169
+ @rows ||= []
170
+ @rows << DataTableRow.new(comments, cells, line)
171
+ end
172
+
173
+ def doc_string(string, content_type, line)
174
+ @doc_string = Formatter::Model::DocString.new(string, content_type, line)
175
+ end
176
+
177
+ def replay(formatter)
178
+ build.replay(formatter)
179
+ end
180
+
181
+ def build
182
+ Step.new(*(@args << @rows << @doc_string))
183
+ end
184
+ end
139
185
  end
140
186
 
141
187
  class Comment < Hashable
@@ -169,10 +215,10 @@ module Gherkin
169
215
  class DocString < Hashable
170
216
  native_impl('gherkin')
171
217
 
172
- attr_reader :content_type, :value, :line
218
+ attr_reader :value, :content_type, :line
173
219
 
174
- def initialize(content_type, value, line)
175
- @content_type, @value, @line = content_type, value, line
220
+ def initialize(value, content_type, line)
221
+ @value, @content_type, @line = value, content_type, line
176
222
  end
177
223
 
178
224
  def line_range
@@ -182,8 +228,6 @@ module Gherkin
182
228
  end
183
229
 
184
230
  class Row < Hashable
185
- native_impl('gherkin')
186
-
187
231
  attr_reader :comments, :cells, :line
188
232
 
189
233
  def initialize(comments, cells, line)
@@ -191,6 +235,20 @@ module Gherkin
191
235
  end
192
236
  end
193
237
 
238
+ class DataTableRow < Row
239
+ native_impl('gherkin')
240
+ end
241
+
242
+ class ExamplesTableRow < Row
243
+ native_impl('gherkin')
244
+ attr_reader :id
245
+
246
+ def initialize(comments, cells, line, id)
247
+ super(comments, cells, line)
248
+ @id = id
249
+ end
250
+ end
251
+
194
252
  class Match < Hashable
195
253
  native_impl('gherkin')
196
254