gherkin 2.0.1-i386-mingw32 → 2.0.2-i386-mingw32

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.
@@ -1,16 +1,19 @@
1
1
  require 'stringio'
2
2
  require 'gherkin/tools/files'
3
3
  require 'gherkin/formatter/pretty_formatter'
4
+ require 'gherkin/parser/formatter_listener'
4
5
 
5
6
  module Gherkin
6
7
  module Tools
7
8
  class Reformat < Files
8
9
  def run
9
10
  each do |file|
10
- purdy = StringIO.new
11
- listener = Formatter::PrettyFormatter.new(purdy)
11
+ io = defined?(JRUBY_VERSION) ? Java.java.io.StringWriter.new : StringIO.new
12
+ formatter = Formatter::PrettyFormatter.new(io, true)
13
+ listener = Parser::FormatterListener.new(formatter)
12
14
  scan(file, listener)
13
- File.open(file, 'w') {|io| io.write(purdy.string)}
15
+ string = defined?(JRUBY_VERSION) ? io.getBuffer.toString : io.string
16
+ File.open(file, 'w') {|io| io.write(string)}
14
17
  end
15
18
  end
16
19
  end
@@ -14,6 +14,9 @@ module Gherkin
14
14
  @steps = 0
15
15
  end
16
16
 
17
+ def location(file, uri)
18
+ end
19
+
17
20
  def tag(name, line)
18
21
  end
19
22
 
@@ -142,9 +142,9 @@ public class <%= @i18n.underscored_iso_code.upcase %> implements Lexer {
142
142
 
143
143
  %% write data noerror;
144
144
 
145
- public void scan(String inputSequence, String uri, int offset) {
145
+ public void scan(String source, String uri, int offset) {
146
146
  listener.location(uri, offset);
147
- String input = inputSequence + "\n%_FEATURE_END_%";
147
+ String input = source + "\n%_FEATURE_END_%";
148
148
  byte[] data = null;
149
149
  try {
150
150
  data = input.getBytes("UTF-8");
@@ -20,7 +20,7 @@
20
20
  ScenarioHeadingEnd = EOL+ space* ( I18N_Feature | I18N_Background | I18N_Scenario | I18N_ScenarioOutline | I18N_Step | '@' | '#' | EOF ) >next_keyword_start;
21
21
  BackgroundHeadingEnd = EOL+ space* ( I18N_Feature | I18N_Scenario | I18N_ScenarioOutline | I18N_Step | '@' | '#'| EOF ) >next_keyword_start;
22
22
  ScenarioOutlineHeadingEnd = EOL+ space* ( I18N_Feature | I18N_Scenario | I18N_Step | '@' | '#' | EOF ) >next_keyword_start;
23
- ExamplesHeadingEnd = EOL+ space* ( I18N_Feature | '|' ) >next_keyword_start;
23
+ ExamplesHeadingEnd = EOL+ space* ( I18N_Feature | '|' | '#') >next_keyword_start;
24
24
 
25
25
  FeatureHeading = space* I18N_Feature %begin_content ^FeatureHeadingEnd* :>> FeatureHeadingEnd @store_feature_content;
26
26
  BackgroundHeading = space* I18N_Background %begin_content ^BackgroundHeadingEnd* :>> BackgroundHeadingEnd @store_background_content;
@@ -0,0 +1,124 @@
1
+ { "name": "Feature Text",
2
+ "keyword": "Feature",
3
+ "description": "In order to test multiline forms",
4
+ "tags": [
5
+ "@tag1",
6
+ "@tag2"
7
+ ],
8
+ "background" : {
9
+ "description": "",
10
+ "name": "",
11
+ "keyword": "Background",
12
+ "steps": [
13
+ { "name": "this is a background step",
14
+ "keyword": "Given " },
15
+ { "name": "this is another one",
16
+ "keyword": "When ",
17
+ "line": 412 }
18
+ ]
19
+ },
20
+ "elements": [
21
+ { "type": "scenario_outline",
22
+ "keyword": "Scenario Outline",
23
+ "name": "An Scenario Outline",
24
+ "description": "",
25
+ "tags": [ "@foo" ],
26
+ "steps": [
27
+ { "name": "A step with a table",
28
+ "keyword": "Given ",
29
+ "table" : [
30
+ {"cells":
31
+ [ "a","row","for","a","step" ]
32
+ }
33
+ ]
34
+ }
35
+ ],
36
+ "examples": [
37
+ { "name": "Sweet Example",
38
+ "keyword": "Examples",
39
+ "description": "",
40
+ "table" : [
41
+ {"cells" :
42
+ [ "Fill","In" ]
43
+ },
44
+ {"cells" :
45
+ [ "The","Blanks" ]
46
+ }
47
+ ],
48
+ "tags" : [ "@exampletag" ]
49
+ }
50
+ ]
51
+ },
52
+ { "type" : "scenario",
53
+ "keyword": "Scenario",
54
+ "name" : "Reading a Scenario",
55
+ "description": "",
56
+ "tags" : [
57
+ "@tag3",
58
+ "@tag4"
59
+ ],
60
+ "steps" : [
61
+ { "name" : "there is a step",
62
+ "keyword": "Given "},
63
+ { "name" : "not another step",
64
+ "keyword": "But " }
65
+ ]
66
+ },
67
+ { "type" : "scenario",
68
+ "keyword": "Scenario",
69
+ "name" : "Reading a second scenario",
70
+ "description": "With two lines of text",
71
+ "tags" : [ "@tag3" ],
72
+ "steps" : [
73
+ { "name" : "a third step with a table",
74
+ "keyword": "Given ",
75
+ "table" : [
76
+ { "cells" :
77
+ [ "a","b" ]
78
+ },
79
+ { "cells" :
80
+ [ "c","d" ]
81
+ },
82
+ { "cells" :
83
+ [ "e", "f" ]
84
+ }
85
+ ]
86
+ },
87
+ { "name" : "I am still testing things",
88
+ "keyword": "Given ",
89
+ "table" : [
90
+ { "cells" :
91
+ [ "g","h" ]
92
+ },
93
+ { "cells" :
94
+ [ "e","r" ]
95
+ },
96
+ { "cells" :
97
+ [ "k", "i" ]
98
+ },
99
+ { "cells" :
100
+ [ "n", "" ]
101
+ }
102
+ ]
103
+ },
104
+ { "name" : "I am done testing these tables",
105
+ "keyword": "Given " },
106
+ { "name" : "I am happy",
107
+ "keyword": "Given " }
108
+ ]
109
+ },
110
+ { "type" : "scenario",
111
+ "keyword": "Scenario",
112
+ "name" : "Hammerzeit",
113
+ "description": "",
114
+ "steps" : [
115
+ { "name" : "All work and no play",
116
+ "keyword": "Given ",
117
+ "py_string" : "Makes Homer something something\nAnd something else" },
118
+ { "name" : "crazy",
119
+ "keyword": "Given " }
120
+ ]
121
+ }
122
+ ]
123
+ }
124
+
@@ -79,6 +79,7 @@ module Gherkin
79
79
 
80
80
  Scenario: Scenario Description
81
81
  description has multiple lines
82
+
82
83
  Given there is a step
83
84
  """
84
85
  with
@@ -97,6 +98,8 @@ module Gherkin
97
98
  @foo
98
99
  Feature: Feature Description
99
100
  Some preamble
101
+ on several
102
+ lines
100
103
 
101
104
  # A Scenario Outline comment
102
105
  @bar
@@ -0,0 +1,97 @@
1
+ #encoding: utf-8
2
+ require 'spec_helper'
3
+ require 'gherkin/json_lexer'
4
+
5
+ module Gherkin
6
+ describe JSONLexer do
7
+
8
+ before do
9
+ @listener = Gherkin::SexpRecorder.new
10
+ @lexer = Gherkin::JSONLexer.new(@listener)
11
+ end
12
+
13
+ describe "An empty feature" do
14
+ it "should scan empty features" do
15
+ @lexer.scan('{}')
16
+ @listener.to_sexp.should == [
17
+ [:eof]
18
+ ]
19
+ end
20
+ end
21
+
22
+ describe "A barely empty feature" do
23
+ it "should scan a feature with no elements" do
24
+ @lexer.scan('{ "keyword": "Feature", "name": "One", "description": "", "line" : 3 }')
25
+ @listener.to_sexp.should == [
26
+ [:feature, "Feature", "One", "", 3],
27
+ [:eof]
28
+ ]
29
+ end
30
+ end
31
+
32
+ describe "Missing line numbers" do
33
+ it "should indicate a line number of 0 if a line attribute doesn't exist" do
34
+ @lexer.scan('{ "name": "My Sweet Featur", "keyword": "Feature", "description": "" }')
35
+ @listener.to_sexp.should == [
36
+ [:feature, "Feature", "My Sweet Featur", "", 0],
37
+ [:eof]
38
+ ]
39
+ end
40
+ end
41
+
42
+ describe "Keywords" do
43
+ it "should use the keyword from the source when provided" do
44
+ @lexer.scan('{ "name" : "My Sweet Featur", "language": "fr", "keyword": "Feature", "description": "" }')
45
+ @listener.to_sexp.should == [
46
+ [:feature, "Feature", "My Sweet Featur", "", 0],
47
+ [:eof]
48
+ ]
49
+ end
50
+ end
51
+
52
+ describe "A complex feature with tags, comments, multiple scenarios, and multiple steps and tables" do
53
+ it "should find things in the right order" do
54
+ scan_file("complex.json")
55
+ @listener.to_sexp.should == [
56
+ [:tag, "@tag1", 0],
57
+ [:tag, "@tag2", 0],
58
+ [:feature, "Feature", "Feature Text","In order to test multiline forms", 0],
59
+ [:background, "Background", "", "", 0],
60
+ [:step, "Given ", "this is a background step", 0],
61
+ [:step, "When ", "this is another one", 412],
62
+ [:tag, "@foo", 0],
63
+ [:scenario_outline, "Scenario Outline", "An Scenario Outline","", 0],
64
+ [:step, "Given ", "A step with a table", 0],
65
+ [:row, %w{a row for a step}, 0],
66
+ [:tag, "@exampletag", 0],
67
+ [:examples, "Examples", "Sweet Example", "", 0],
68
+ [:row, %w{Fill In}, 0],
69
+ [:row, %w{The Blanks}, 0],
70
+ [:tag, "@tag3", 0],
71
+ [:tag, "@tag4", 0],
72
+ [:scenario, "Scenario", "Reading a Scenario", "", 0],
73
+ [:step, "Given ", "there is a step", 0],
74
+ [:step, "But ", "not another step", 0],
75
+ [:tag, "@tag3", 0],
76
+ [:scenario, "Scenario", "Reading a second scenario", "With two lines of text", 0],
77
+ [:step, "Given ", "a third step with a table", 0],
78
+ [:row, %w{a b}, 0],
79
+ [:row, %w{c d}, 0],
80
+ [:row, %w{e f}, 0],
81
+ [:step, "Given ", "I am still testing things", 0],
82
+ [:row, %w{g h}, 0],
83
+ [:row, %w{e r}, 0],
84
+ [:row, %w{k i}, 0],
85
+ [:row, ['n', ''], 0],
86
+ [:step, "Given ", "I am done testing these tables", 0],
87
+ [:step, "Given ", "I am happy", 0],
88
+ [:scenario, "Scenario", "Hammerzeit", "", 0],
89
+ [:step, "Given ", "All work and no play", 0],
90
+ [:py_string, "Makes Homer something something\nAnd something else", 0 ],
91
+ [:step, "Given ", "crazy", 0],
92
+ [:eof]
93
+ ]
94
+ end
95
+ end
96
+ end
97
+ end
@@ -39,6 +39,18 @@ module Gherkin
39
39
  ]
40
40
  end
41
41
 
42
+ it "should not consume comments as part of a multiline example name" do
43
+ scan("Examples: thing\n# ho hum\n| 1 | 2 |\n| 3 | 4 |\n")
44
+ @listener.to_sexp.should == [
45
+ [:location, 'test.feature', 0],
46
+ [:examples, "Examples", "thing", "", 1],
47
+ [:comment, "# ho hum", 2],
48
+ [:row, ["1","2"], 3],
49
+ [:row, ["3","4"], 4],
50
+ [:eof]
51
+ ]
52
+ end
53
+
42
54
  it "should allow empty comment lines" do
43
55
  scan("#\n # A comment\n #\n")
44
56
  @listener.to_sexp.should == [
@@ -1,25 +1,19 @@
1
+ require 'rubygems'
2
+ require 'rspec/autorun'
1
3
  require 'gherkin'
2
4
  require 'stringio'
3
5
  require 'gherkin/sexp_recorder'
4
6
  require 'gherkin/output_stream_string_io'
5
- require 'rubygems'
6
- require 'rspec/autorun'
7
7
  require 'gherkin/shared/lexer_group'
8
8
  require 'gherkin/shared/tags_group'
9
9
  require 'gherkin/shared/py_string_group'
10
10
  require 'gherkin/shared/row_group'
11
11
 
12
12
  module GherkinSpecHelper
13
- # TODO: Rename to gherkin_scan_file
14
13
  def scan_file(file)
15
14
  @lexer.scan(File.new(File.dirname(__FILE__) + "/gherkin/fixtures/" + file).read, file, 0)
16
15
  end
17
16
 
18
- # TODO: Remove
19
- def parse_file(file)
20
- @parser.parse(File.new(File.dirname(__FILE__) + "/gherkin/fixtures/" + file).read)
21
- end
22
-
23
17
  def rubify_hash(hash)
24
18
  if defined?(JRUBY_VERSION)
25
19
  h = {}
@@ -24,15 +24,29 @@ end
24
24
  rl_langs = ENV['RL_LANGS'] ? ENV['RL_LANGS'].split(',') : []
25
25
  langs = Gherkin::I18n.all.select { |lang| rl_langs.empty? || rl_langs.include?(lang.iso_code) }
26
26
 
27
+ # http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6457127
28
+ file 'lib/gherkin.jar' => "java/src/main/resources/gherkin/I18nKeywords_in.properties"
29
+ file "java/src/main/resources/gherkin/I18nKeywords_in.properties" => "java/src/main/resources/gherkin/I18nKeywords_id.properties" do
30
+ cp "java/src/main/resources/gherkin/I18nKeywords_id.properties", "java/src/main/resources/gherkin/I18nKeywords_in.properties"
31
+ end
32
+
33
+ # http://forums.sun.com/thread.jspa?threadID=5335461
34
+ file 'lib/gherkin.jar' => "java/src/main/resources/gherkin/I18nKeywords_iw.properties"
35
+ file "java/src/main/resources/gherkin/I18nKeywords_iw.properties" => "java/src/main/resources/gherkin/I18nKeywords_he.properties" do
36
+ cp "java/src/main/resources/gherkin/I18nKeywords_he.properties", "java/src/main/resources/gherkin/I18nKeywords_iw.properties"
37
+ end
38
+
27
39
  langs.each do |i18n|
28
40
  java = RagelTask.new('java', i18n)
29
41
  rb = RagelTask.new('rb', i18n)
30
42
 
31
- java_properties = "java/src/main/resources/gherkin/I18nKeywords_#{i18n.iso_code.gsub(/-/, '_')}.properties"
43
+ lang_country = i18n.iso_code.split(/-/)
44
+ suffix = lang_country.length == 1 ? lang_country[0] : "#{lang_country[0]}_#{lang_country[1].upcase}"
45
+ java_properties = "java/src/main/resources/gherkin/I18nKeywords_#{suffix}.properties"
32
46
  file java_properties => 'lib/gherkin/i18n.yml' do
33
47
  File.open(java_properties, 'wb') do |io|
34
48
  io.puts("# Generated file. Do not edit.")
35
- Gherkin::I18n::KEYWORD_KEYS.each do |key|
49
+ (Gherkin::I18n::KEYWORD_KEYS + %w{name native}).each do |key|
36
50
  value = Gherkin::I18n.unicode_escape(i18n.keywords(key).join("|"))
37
51
  io.puts("#{key}:#{value}")
38
52
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gherkin
3
3
  version: !ruby/object:Gem::Version
4
- hash: 13
4
+ hash: 11
5
5
  prerelease: false
6
6
  segments:
7
7
  - 2
8
8
  - 0
9
- - 1
10
- version: 2.0.1
9
+ - 2
10
+ version: 2.0.2
11
11
  platform: i386-mingw32
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-06-15 00:00:00 +02:00
20
+ date: 2010-06-16 00:00:00 +02:00
21
21
  default_executable: gherkin
22
22
  dependencies:
23
23
  - !ruby/object:Gem::Dependency
@@ -110,12 +110,14 @@ files:
110
110
  - features/escaped_pipes.feature
111
111
  - features/feature_parser.feature
112
112
  - features/json_formatter.feature
113
+ - features/json_parser.feature
113
114
  - features/native_lexer.feature
114
115
  - features/parser_with_native_lexer.feature
115
116
  - features/pretty_formatter.feature
116
117
  - features/step_definitions/eyeball_steps.rb
117
118
  - features/step_definitions/gherkin_steps.rb
118
119
  - features/step_definitions/json_formatter_steps.rb
120
+ - features/step_definitions/json_lexer_steps.rb
119
121
  - features/step_definitions/pretty_formatter_steps.rb
120
122
  - features/steps_parser.feature
121
123
  - features/support/env.rb
@@ -224,6 +226,7 @@ files:
224
226
  - lib/gherkin/i18n.rb
225
227
  - lib/gherkin/i18n.yml
226
228
  - lib/gherkin/i18n_lexer.rb
229
+ - lib/gherkin/json_lexer.rb
227
230
  - lib/gherkin/native.rb
228
231
  - lib/gherkin/native/ikvm.rb
229
232
  - lib/gherkin/native/java.rb
@@ -231,7 +234,6 @@ files:
231
234
  - lib/gherkin/parser/event.rb
232
235
  - lib/gherkin/parser/filter_listener.rb
233
236
  - lib/gherkin/parser/formatter_listener.rb
234
- - lib/gherkin/parser/json_parser.rb
235
237
  - lib/gherkin/parser/meta.txt
236
238
  - lib/gherkin/parser/parser.rb
237
239
  - lib/gherkin/parser/root.txt
@@ -256,7 +258,7 @@ files:
256
258
  - spec/gherkin/fixtures/1.feature
257
259
  - spec/gherkin/fixtures/comments_in_table.feature
258
260
  - spec/gherkin/fixtures/complex.feature
259
- - spec/gherkin/fixtures/complex.js
261
+ - spec/gherkin/fixtures/complex.json
260
262
  - spec/gherkin/fixtures/dos_line_endings.feature
261
263
  - spec/gherkin/fixtures/i18n_fr.feature
262
264
  - spec/gherkin/fixtures/i18n_no.feature
@@ -272,10 +274,10 @@ files:
272
274
  - spec/gherkin/i18n_lexer_spec.rb
273
275
  - spec/gherkin/i18n_spec.rb
274
276
  - spec/gherkin/java_lexer_spec.rb
277
+ - spec/gherkin/json_lexer_spec.rb
275
278
  - spec/gherkin/output_stream_string_io.rb
276
279
  - spec/gherkin/parser/filter_listener_spec.rb
277
280
  - spec/gherkin/parser/formatter_listener_spec.rb
278
- - spec/gherkin/parser/json_parser_spec.rb
279
281
  - spec/gherkin/parser/parser_spec.rb
280
282
  - spec/gherkin/parser/tag_expression_spec.rb
281
283
  - spec/gherkin/rb_lexer_spec.rb
@@ -339,10 +341,10 @@ test_files:
339
341
  - spec/gherkin/i18n_lexer_spec.rb
340
342
  - spec/gherkin/i18n_spec.rb
341
343
  - spec/gherkin/java_lexer_spec.rb
344
+ - spec/gherkin/json_lexer_spec.rb
342
345
  - spec/gherkin/output_stream_string_io.rb
343
346
  - spec/gherkin/parser/filter_listener_spec.rb
344
347
  - spec/gherkin/parser/formatter_listener_spec.rb
345
- - spec/gherkin/parser/json_parser_spec.rb
346
348
  - spec/gherkin/parser/parser_spec.rb
347
349
  - spec/gherkin/parser/tag_expression_spec.rb
348
350
  - spec/gherkin/rb_lexer_spec.rb