gherkin 2.11.6-java → 2.11.7-java

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.
@@ -13,7 +13,6 @@ Bundler.setup
13
13
  end
14
14
  require 'gherkin'
15
15
  require 'gherkin/sexp_recorder'
16
- require 'gherkin/output_stream_string_io'
17
16
 
18
17
  module TransformHelpers
19
18
  def tr_line_number(step_arg)
@@ -31,12 +30,12 @@ end
31
30
 
32
31
  class GherkinWorld
33
32
  include TransformHelpers
34
-
33
+
35
34
  def initialize
36
35
  @formatter = Gherkin::SexpRecorder.new
37
36
  end
38
37
  end
39
38
 
40
- World do
39
+ World do
41
40
  GherkinWorld.new
42
41
  end
data/gherkin.gemspec CHANGED
@@ -1,4 +1,6 @@
1
1
  # -*- encoding: utf-8 -*-
2
+ $LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
3
+ require 'gherkin/platform'
2
4
 
3
5
  Gem::Specification.new do |s|
4
6
  s.name = "gherkin"
@@ -12,10 +14,10 @@ Gem::Specification.new do |s|
12
14
  #
13
15
  # Repeat these step for cucumber (swap `cucumber` with `gherkin`).
14
16
  #
15
- # When both are building OK, do a `bundle exec rake install` in both cucumber and gherkin projects, revert the changes in the first 2 steps
17
+ # When both are building OK, do a `bundle exec rake install` in both cucumber and gherkin projects, revert the changes in the first 2 steps
16
18
  # and release both projects. Do this for both ruby 1.8.7, ruby 1.9.3 and jruby.
17
19
  #
18
- s.version = "2.11.6"
20
+ s.version = Gherkin::VERSION
19
21
  s.authors = ["Mike Sassak", "Gregory Hnatiuk", "Aslak Hellesøy"]
20
22
  s.description = "A fast Gherkin lexer/parser based on the Ragel State Machine Compiler."
21
23
  s.summary = "#{s.name}-#{s.version}"
@@ -36,11 +38,11 @@ Gem::Specification.new do |s|
36
38
  s.files -= Dir['lib/**/*.dll']
37
39
  s.files -= Dir['lib/**/*.bundle']
38
40
  s.files -= Dir['lib/**/*.so']
39
-
41
+
40
42
  if ENV['GEM_PLATFORM']
41
43
  puts "GEM_PLATFORM:#{ENV['GEM_PLATFORM']}"
42
44
  end
43
- s.platform = ENV['GEM_PLATFORM'] if ENV['GEM_PLATFORM']
45
+ s.platform = ENV['GEM_PLATFORM'] if ENV['GEM_PLATFORM']
44
46
  case s.platform.to_s
45
47
  when /java/
46
48
  s.files += Dir['lib/*.jar']
@@ -56,7 +58,7 @@ Gem::Specification.new do |s|
56
58
  end
57
59
  s.files -= Dir['**/.gitignore']
58
60
 
59
- s.add_runtime_dependency('json', '>= 1.7.6')
61
+ s.add_runtime_dependency('multi_json', '~> 1.3')
60
62
 
61
63
  s.add_development_dependency('cucumber', '>= 1.2.1')
62
64
  s.add_development_dependency('rake', '>= 10.0.3')
@@ -64,7 +66,7 @@ Gem::Specification.new do |s|
64
66
  s.add_development_dependency('rspec', '~> 2.12.0')
65
67
  s.add_development_dependency('rubyzip', '>= 0.9.9')
66
68
 
67
- unless ENV['RUBY_CC_VERSION'] || defined?(JRUBY_VERSION)
69
+ unless ENV['RUBY_CC_VERSION'] || Gherkin::JRUBY
68
70
  s.add_development_dependency('therubyracer', '>= 0.11.2') if ENV['GHERKIN_JS']
69
71
  # For Documentation:
70
72
  s.add_development_dependency('yard', '>= 0.8.3')
data/lib/gherkin.jar CHANGED
Binary file
@@ -1,4 +1,4 @@
1
- require 'json'
1
+ require 'multi_json'
2
2
  require 'gherkin/formatter/model'
3
3
  require 'gherkin/native'
4
4
  require 'base64'
@@ -9,9 +9,9 @@ module Gherkin
9
9
  # be turned into JSON.
10
10
  class JSONFormatter
11
11
  native_impl('gherkin')
12
-
12
+
13
13
  include Base64
14
-
14
+
15
15
  def initialize(io)
16
16
  raise "Must be writeable" unless io.respond_to?(:write)
17
17
  @io = io
@@ -20,7 +20,7 @@ module Gherkin
20
20
  end
21
21
 
22
22
  def done
23
- @io.write(@feature_hashes.to_json)
23
+ @io.write(MultiJson.dump(@feature_hashes, :pretty => true))
24
24
  end
25
25
 
26
26
  def uri(uri)
@@ -61,7 +61,7 @@ module Gherkin
61
61
  def result(result)
62
62
  @current_step_or_hook['result'] = result.to_hash
63
63
  end
64
-
64
+
65
65
  def append_duration(timestamp)
66
66
  #check to make sure result exists (scenario outlines do not have results yet)
67
67
  if !@current_step_or_hook['result'].nil?
@@ -8,7 +8,7 @@ module Gherkin
8
8
  end
9
9
 
10
10
  def eval(tags, names, ranges)
11
- @tag_expression.eval(tags.uniq)
11
+ @tag_expression.evaluate(tags.uniq)
12
12
  end
13
13
 
14
14
  def filter_table_body_rows(rows)
@@ -16,4 +16,4 @@ module Gherkin
16
16
  end
17
17
  end
18
18
  end
19
- end
19
+ end
@@ -125,6 +125,20 @@
125
125
  "and": "*|Und",
126
126
  "but": "*|Aber"
127
127
  },
128
+ "el": {
129
+ "name": "Greek",
130
+ "native": "Ελληνικά",
131
+ "feature": "Δυνατότητα|Λειτουργία",
132
+ "background": "Υπόβαθρο",
133
+ "scenario": "Σενάριο",
134
+ "scenario_outline": "Περιγραφή Σεναρίου",
135
+ "examples": "Παραδείγματα|Σενάρια",
136
+ "given": "*|Δεδομένου|Δεδομένου ότι",
137
+ "when": "*|Όταν",
138
+ "then": "*|Τότε",
139
+ "and": "*|Και",
140
+ "but": "*|Αλλά"
141
+ },
128
142
  "en-au": {
129
143
  "name": "Australian",
130
144
  "native": "Australian",
@@ -153,6 +167,20 @@
153
167
  "and": "*|AN",
154
168
  "but": "*|BUT"
155
169
  },
170
+ "en-old": {
171
+ "name": "Old English",
172
+ "native": "Englisc",
173
+ "feature": "Hwaet|Hwæt",
174
+ "background": "Aer|Ær",
175
+ "scenario": "Swa",
176
+ "scenario_outline": "Swa hwaer swa|Swa hwær swa",
177
+ "examples": "Se the|Se þe|Se ðe",
178
+ "given": "*|Thurh|Þurh|Ðurh",
179
+ "when": "*|Tha|Þa|Ða",
180
+ "then": "*|Tha|Þa|Ða|Tha the|Þa þe|Ða ðe",
181
+ "and": "*|Ond|7",
182
+ "but": "*|Ac"
183
+ },
156
184
  "en-pirate": {
157
185
  "name": "Pirate",
158
186
  "native": "Pirate",
data/lib/gherkin/i18n.rb CHANGED
@@ -1,6 +1,6 @@
1
- require 'json'
2
1
  require 'gherkin/rubify'
3
2
  require 'gherkin/native'
3
+ require 'multi_json'
4
4
 
5
5
  module Gherkin
6
6
  class I18n
@@ -11,7 +11,7 @@ module Gherkin
11
11
  FEATURE_ELEMENT_KEYS = %w{feature background scenario scenario_outline examples}
12
12
  STEP_KEYWORD_KEYS = %w{given when then and but}
13
13
  KEYWORD_KEYS = FEATURE_ELEMENT_KEYS + STEP_KEYWORD_KEYS
14
- LANGUAGES = JSON.parse(File.open(File.dirname(__FILE__) + '/i18n.json', 'r:utf-8').read)
14
+ LANGUAGES = MultiJson.load(File.open(File.dirname(__FILE__) + '/i18n.json', 'r:utf-8').read)
15
15
 
16
16
  class << self
17
17
  include Rubify
@@ -30,7 +30,7 @@ module Gherkin
30
30
  # there is typically a code generation tool to generate regular expressions for recognising the
31
31
  # various I18n translations of Gherkin's keywords.
32
32
  #
33
- # The +keywords+ arguments can be one of <tt>:feature</tt>, <tt>:background</tt>, <tt>:scenario</tt>,
33
+ # The +keywords+ arguments can be one of <tt>:feature</tt>, <tt>:background</tt>, <tt>:scenario</tt>,
34
34
  # <tt>:scenario_outline</tt>, <tt>:examples</tt>, <tt>:step</tt>.
35
35
  def keyword_regexp(*keywords)
36
36
  unique_keywords = all.map do |i18n|
@@ -42,7 +42,7 @@ module Gherkin
42
42
  end
43
43
  end
44
44
  end
45
-
45
+
46
46
  unique_keywords.flatten.compact.map{|kw| kw.to_s}.sort.reverse.uniq.join('|').gsub(/\*/, '\*')
47
47
  end
48
48
 
@@ -150,14 +150,14 @@ module Gherkin
150
150
  gherkin_keyword_table = KEYWORD_KEYS.map do |key|
151
151
  Formatter::Model::Row.new([], [key, keywords(key).map{|keyword| %{"#{keyword}"}}.join(', ')], nil)
152
152
  end
153
-
153
+
154
154
  code_keyword_table = STEP_KEYWORD_KEYS.map do |key|
155
155
  code_keywords = keywords(key).reject{|keyword| keyword == '* '}.map do |keyword|
156
156
  %{"#{self.class.code_keyword_for(keyword)}"}
157
157
  end.join(', ')
158
158
  Formatter::Model::Row.new([], ["#{key} (code)", code_keywords], nil)
159
159
  end
160
-
160
+
161
161
  pf.table(gherkin_keyword_table + code_keyword_table)
162
162
  io.string
163
163
  end
@@ -1,8 +1,8 @@
1
- require 'json'
2
- require 'gherkin/formatter/model'
1
+ require 'base64'
3
2
  require 'gherkin/formatter/argument'
3
+ require 'gherkin/formatter/model'
4
4
  require 'gherkin/native'
5
- require 'base64'
5
+ require 'multi_json'
6
6
 
7
7
  module Gherkin
8
8
  class JSONParser
@@ -17,7 +17,7 @@ module Gherkin
17
17
  # Parse a gherkin object +o+, which can either be a JSON String,
18
18
  # or a Hash (from a parsed JSON String).
19
19
  def parse(o)
20
- o = JSON.parse(o) if String === o
20
+ o = MultiJson.load(o) if String === o
21
21
 
22
22
  o.each do |f|
23
23
  @formatter.uri(f['uri'])
@@ -32,7 +32,7 @@ class Class
32
32
  e.message << "\n#{java_class.name}"
33
33
  raise e
34
34
  rescue NameError => e
35
- e.message << "\n args: #{args.inspect}"
35
+ e.message << "\n args: #{args.inspect}"
36
36
  raise e
37
37
  end
38
38
  end
@@ -46,7 +46,7 @@ class Class
46
46
  java.util.regex.Pattern.compile(arg.source)
47
47
  when Symbol
48
48
  arg.to_s
49
- when IO
49
+ when IO, StringIO
50
50
  IOWriter.new(arg)
51
51
  else
52
52
  arg
@@ -27,6 +27,7 @@ module Gherkin
27
27
  def parse(gherkin, feature_uri, line_offset)
28
28
  @formatter.uri(feature_uri)
29
29
  @line_offset = line_offset
30
+ @feature_uri = feature_uri
30
31
  push_machine(@machine_name)
31
32
  begin
32
33
  @lexer.scan(gherkin)
@@ -0,0 +1,12 @@
1
+ # Detect the platform we're running and warn if it is not supported
2
+
3
+ module Gherkin
4
+ unless defined?(Gherkin::VERSION)
5
+ VERSION = '2.11.7'
6
+ JRUBY = defined?(JRUBY_VERSION)
7
+
8
+ if !JRUBY && !(RUBY_VERSION =~ /^(1\.8\.7|1\.9\.3|2\.0)/)
9
+ warn("WARNING: Unsupported Ruby version - #{RUBY_VERSION}")
10
+ end
11
+ end
12
+ end
@@ -18,7 +18,13 @@ module Gherkin
18
18
  @ands.empty?
19
19
  end
20
20
 
21
+ # <b>DEPRECATED:</b> Please use <tt>evaluate</tt> instead
21
22
  def eval(tags)
23
+ warn '[DEPRECATION] "eval" is deprecated. Please use "evaluate" instead'
24
+ evaluate(tags)
25
+ end
26
+
27
+ def evaluate(tags)
22
28
  return true if @ands.flatten.empty?
23
29
  vars = Hash[*tags.map{|tag| [tag.name, true]}.flatten]
24
30
  !!Kernel.eval(ruby_expression)
@@ -39,7 +45,7 @@ module Gherkin
39
45
  if limit
40
46
  tag_without_negation = negated ? tag_with_negation[1..-1] : tag_with_negation
41
47
  if @limits[tag_without_negation] && @limits[tag_without_negation] != limit.to_i
42
- raise "Inconsistent tag limits for #{tag_without_negation}: #{@limits[tag_without_negation]} and #{limit.to_i}"
48
+ raise "Inconsistent tag limits for #{tag_without_negation}: #{@limits[tag_without_negation]} and #{limit.to_i}"
43
49
  end
44
50
  @limits[tag_without_negation] = limit.to_i
45
51
  end
@@ -1,7 +1,8 @@
1
1
  require 'spec_helper'
2
- require 'stringio'
3
2
  require 'gherkin/formatter/json_formatter'
4
3
  require 'gherkin/formatter/model'
4
+ require 'multi_json'
5
+ require 'stringio'
5
6
 
6
7
  module Gherkin
7
8
  module Formatter
@@ -25,7 +26,7 @@ module Gherkin
25
26
 
26
27
  f.eof
27
28
  f.done
28
-
29
+
29
30
  expected = %{
30
31
  [
31
32
  {
@@ -85,7 +86,77 @@ module Gherkin
85
86
  }
86
87
  ]
87
88
  }
88
- JSON.parse(expected).should == JSON.parse(io.string)
89
+ MultiJson.load(expected).should == MultiJson.load(io.string)
90
+ end
91
+
92
+ it "renders results as pretty json" do
93
+ io = StringIO.new
94
+ f = JSONFormatter.new(io)
95
+ f.uri("f.feature")
96
+ f.feature(Model::Feature.new([], [], "Feature", nil, nil, nil, nil))
97
+ f.eof
98
+ f.done
99
+
100
+ expected = %{
101
+ [
102
+ {
103
+ "keyword": "Feature",
104
+ "uri": "f.feature"
105
+ }
106
+ ]
107
+ }
108
+ io.string.should == MultiJson.dump(MultiJson.load(expected), :pretty => true)
109
+ end
110
+
111
+ it 'supports append_duration' do
112
+ io = StringIO.new
113
+ f = JSONFormatter.new(io)
114
+ f.uri("f.feature")
115
+ f.feature(Model::Feature.new([], [], "Feature", "ff", "", 1, "ff"))
116
+ f.scenario(Model::Scenario.new([], [], "Scenario", "ss", "", 2, "ff/ss"))
117
+ f.step(Model::Step.new([], "Given ", "g", 3, nil, nil))
118
+ f.match(Model::Match.new([], "def.rb:33"))
119
+ f.result(Model::Result.new(:passed, 3, nil))
120
+ f.append_duration(1)
121
+ f.eof
122
+ f.done
123
+ expected = %{
124
+ [
125
+ {
126
+ "id": "ff",
127
+ "uri": "f.feature",
128
+ "keyword": "Feature",
129
+ "name": "ff",
130
+ "line": 1,
131
+ "description": "",
132
+ "elements": [
133
+ {
134
+ "id": "ff/ss",
135
+ "keyword": "Scenario",
136
+ "name": "ss",
137
+ "line": 2,
138
+ "description": "",
139
+ "type": "scenario",
140
+ "steps": [
141
+ {
142
+ "keyword": "Given ",
143
+ "name": "g",
144
+ "line": 3,
145
+ "match": {
146
+ "location": "def.rb:33"
147
+ },
148
+ "result": {
149
+ "status": "passed",
150
+ "duration": 1000000000
151
+ }
152
+ }
153
+ ]
154
+ }
155
+ ]
156
+ }
157
+ ]
158
+ }
159
+ MultiJson.load(expected).should == MultiJson.load(io.string)
89
160
  end
90
161
  end
91
162
  end
@@ -175,10 +175,12 @@ module Gherkin
175
175
  | cy-GB | Welsh | Cymraeg |
176
176
  | da | Danish | dansk |
177
177
  | de | German | Deutsch |
178
+ | el | Greek | Ελληνικά |
178
179
  | en | English | English |
179
180
  | en-Scouse | Scouse | Scouse |
180
181
  | en-au | Australian | Australian |
181
182
  | en-lol | LOLCAT | LOLCAT |
183
+ | en-old | Old English | Englisc |
182
184
  | en-pirate | Pirate | Pirate |
183
185
  | en-tx | Texan | Texan |
184
186
  | eo | Esperanto | Esperanto |
@@ -3,9 +3,10 @@ require 'stringio'
3
3
  require 'spec_helper'
4
4
  require 'gherkin/json_parser'
5
5
  require 'gherkin/formatter/json_formatter'
6
+ require 'multi_json'
6
7
 
7
8
  module Gherkin
8
- describe JSONParser do
9
+ describe JSONParser do
9
10
 
10
11
  def check_json(json)
11
12
  io = StringIO.new
@@ -13,8 +14,8 @@ module Gherkin
13
14
  p = JSONParser.new(f, f)
14
15
  p.parse(json)
15
16
  f.done
16
- expected = JSON.parse(json)
17
- actual = JSON.parse(io.string)
17
+ expected = MultiJson.load(json)
18
+ actual = MultiJson.load(io.string)
18
19
 
19
20
  begin
20
21
  actual.should == expected
@@ -34,10 +35,10 @@ module Gherkin
34
35
  {
35
36
  "id": "one",
36
37
  "uri": "test.feature",
37
- "keyword": "Feature",
38
- "name": "One",
39
- "description": "",
40
- "line" : 3
38
+ "keyword": "Feature",
39
+ "name": "One",
40
+ "description": "",
41
+ "line" : 3
41
42
  }
42
43
  ]})
43
44
  end
@@ -53,9 +54,9 @@ module Gherkin
53
54
  "line": 22
54
55
  }
55
56
  ],
56
- "keyword": "Feature",
57
- "name": "One",
58
- "description": "",
57
+ "keyword": "Feature",
58
+ "name": "One",
59
+ "description": "",
59
60
  "line": 3,
60
61
  "elements": [
61
62
  {