gherkin 2.10.0-java → 2.11.0-java

Sign up to get free protection for your applications and to get access to all the features.
data/History.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## [2.11.0](https://github.com/cucumber/gherkin/compare/v2.10.0...v2.11.0)
2
+
3
+ * [Core] Alias Feature with Business Need and Ability. ([#167](https://github.com/cucumber/gherkin/issues/167) Aslak Hellesøy)
4
+ * [Java] Better exception on bad filter mix. ([#179](https://github.com/cucumber/gherkin/issues/179) Aslak Hellesøy)
5
+ * [Java, Ruby] Formatters don't deal well with things not associated with a step ([#172](https://github.com/cucumber/gherkin/issues/172) David Kowis, Aslak Hellesøy)
6
+ * [Java] Make model classes implement `java.io.Serializable` ([#180](https://github.com/cucumber/gherkin/issues/180) Aslak Hellesøy)
7
+
1
8
  ## [2.10.0](https://github.com/cucumber/gherkin/compare/v2.9.3...v2.10.0)
2
9
 
3
10
  * [Core] Added Malay language support. ([#176](https://github.com/cucumber/gherkin/pull/176) Choon Siong)
data/README.md CHANGED
@@ -1,5 +1,4 @@
1
1
  [![Build Status](https://secure.travis-ci.org/cucumber/gherkin.png)](http://travis-ci.org/cucumber/gherkin)
2
- [![Dependency Status](https://gemnasium.com/cucumber/gherkin.png)](https://gemnasium.com/cucumber/gherkin)
3
2
 
4
3
  A fast lexer and parser for the Gherkin language based on Ragel. Gherkin is two things:
5
4
 
@@ -55,7 +54,7 @@ The jar file is in the central Maven repo.
55
54
  <dependency>
56
55
  <groupId>info.cukes</groupId>
57
56
  <artifactId>gherkin</artifactId>
58
- <version>2.10.0</version>
57
+ <version>2.11.0</version>
59
58
  </dependency>
60
59
 
61
60
  You can get it manually from [Maven Central](http://search.maven.org/#browse%7C-2073395818)
@@ -203,7 +202,7 @@ Now we're ready to install the Windows rubies:
203
202
  rvm gemset use cucumber
204
203
  gem install bundler
205
204
  bundle install
206
- PATH=/usr/local/mingw/bin:$PATH CC=/usr/local/mingw/bin/i686-w64-mingw32-gcc rake-compiler cross-ruby VERSION=1.9.3-p194
205
+ PATH=/usr/local/mingw/bin:$PATH CC=/usr/local/mingw/bin/i686-w64-mingw32-gcc rake-compiler cross-ruby VERSION=1.9.3-p194
207
206
 
208
207
  # 1.8.7
209
208
  CC=gcc-4.2 rvm install 1.8.7-p352
@@ -217,7 +216,7 @@ Now we're ready to install the Windows rubies:
217
216
  Now you can build Windows gems:
218
217
 
219
218
  rake compile
220
- mkdir release
219
+ mkdir release
221
220
  rake gems:win
222
221
 
223
222
  ## Release process
@@ -15,7 +15,7 @@ Gem::Specification.new do |s|
15
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
16
16
  # and release both projects. Do this for both ruby 1.8.7, ruby 1.9.3 and jruby.
17
17
  #
18
- s.version = "2.10.0"
18
+ s.version = "2.11.0"
19
19
  s.authors = ["Mike Sassak", "Gregory Hnatiuk", "Aslak Hellesøy"]
20
20
  s.description = "A fast Gherkin lexer/parser based on the Ragel State Machine Compiler."
21
21
  s.summary = "#{s.name}-#{s.version}"
@@ -58,10 +58,10 @@ Gem::Specification.new do |s|
58
58
 
59
59
  s.add_runtime_dependency('json', '>= 1.4.6')
60
60
 
61
- s.add_development_dependency('cucumber', '>= 1.2.0')
61
+ s.add_development_dependency('cucumber', '>= 1.2.1')
62
62
  s.add_development_dependency('rake', '>= 0.9.2')
63
63
  s.add_development_dependency('bundler', '>= 1.1.0')
64
- s.add_development_dependency('rspec', '~> 2.9.0')
64
+ s.add_development_dependency('rspec', '~> 2.10.0')
65
65
  s.add_development_dependency('rubyzip', '>= 0.9.8')
66
66
 
67
67
  unless ENV['RUBY_CC_VERSION'] || defined?(JRUBY_VERSION)
Binary file
@@ -96,7 +96,7 @@ module Gherkin
96
96
  private
97
97
 
98
98
  def detect_filter(filters)
99
- raise "Inconsistent filters: #{filters.inspect}" if filters.map{|filter| filter.class}.uniq.length > 1
99
+ raise "Inconsistent filters: #{filters.inspect}. Only one type [line,name,tag] can be used at once." if filters.map{|filter| filter.class}.uniq.length > 1
100
100
  case(filters[0])
101
101
  when Fixnum
102
102
  LineFilter.new(filters)
@@ -16,6 +16,7 @@ module Gherkin
16
16
  raise "Must be writeable" unless io.respond_to?(:write)
17
17
  @io = io
18
18
  @feature_hashes = []
19
+ @current_step_or_hook = nil
19
20
  end
20
21
 
21
22
  def done
@@ -34,17 +35,14 @@ module Gherkin
34
35
 
35
36
  def background(background)
36
37
  feature_elements << background.to_hash
37
- @step_index = 0
38
38
  end
39
39
 
40
40
  def scenario(scenario)
41
41
  feature_elements << scenario.to_hash
42
- @step_index = 0
43
42
  end
44
43
 
45
44
  def scenario_outline(scenario_outline)
46
45
  feature_elements << scenario_outline.to_hash
47
- @step_index = 0
48
46
  end
49
47
 
50
48
  def examples(examples)
@@ -52,31 +50,44 @@ module Gherkin
52
50
  end
53
51
 
54
52
  def step(step)
55
- current_steps << step.to_hash
53
+ @current_step_or_hook = step.to_hash
54
+ steps << @current_step_or_hook
56
55
  end
57
56
 
58
57
  def match(match)
59
- current_steps[@step_index]['match'] = match.to_hash
58
+ @current_step_or_hook['match'] = match.to_hash
60
59
  end
61
60
 
62
61
  def result(result)
63
- current_steps[@step_index]['result'] = result.to_hash
64
- @step_index += 1
62
+ @current_step_or_hook['result'] = result.to_hash
65
63
  end
66
64
 
67
- def last_step
68
- current_steps[-1]
65
+ def before(match, result)
66
+ add_hook(match, result, "before")
67
+ end
68
+
69
+ def after(match, result)
70
+ add_hook(match, result, "after")
69
71
  end
70
72
 
71
73
  def embedding(mime_type, data)
72
74
  embeddings << {'mime_type' => mime_type, 'data' => encode64s(data)}
73
75
  end
74
76
 
77
+ def write(text)
78
+ output << text
79
+ end
80
+
75
81
  def eof
76
82
  end
77
83
 
78
84
  private
79
85
 
86
+ def add_hook(match, result, hook)
87
+ hooks = (feature_element[hook] ||= []);
88
+ hooks << {'match' => match.to_hash, 'result' => result.to_hash}
89
+ end
90
+
80
91
  def feature_elements
81
92
  @feature_hash['elements'] ||= []
82
93
  end
@@ -89,12 +100,16 @@ module Gherkin
89
100
  feature_element['examples'] ||= []
90
101
  end
91
102
 
92
- def current_steps
103
+ def steps
93
104
  feature_element['steps'] ||= []
94
105
  end
95
106
 
96
107
  def embeddings
97
- last_step['embeddings'] ||= []
108
+ @current_step_or_hook['embeddings'] ||= []
109
+ end
110
+
111
+ def output
112
+ @current_step_or_hook['output'] ||= []
98
113
  end
99
114
 
100
115
  def encode64s(data)
@@ -13,7 +13,7 @@
13
13
  "en":
14
14
  name: English
15
15
  native: English
16
- feature: Feature
16
+ feature: Feature|Business Need|Ability
17
17
  background: Background
18
18
  scenario: Scenario
19
19
  scenario_outline: Scenario Outline|Scenario Template
@@ -24,12 +24,23 @@ module Gherkin
24
24
  Formatter::Model::Feature.new(comments(f), tags(f), keyword(f), name(f), description(f), line(f), id(f)).replay(@formatter)
25
25
  (f["elements"] || []).each do |feature_element|
26
26
  feature_element(feature_element).replay(@formatter)
27
+
28
+ (feature_element["before"] || []).each do |hook|
29
+ before(hook)
30
+ end
31
+
27
32
  (feature_element["steps"] || []).each do |step|
28
33
  step(step).replay(@formatter)
29
34
  match(step)
30
35
  result(step)
31
36
  embeddings(step)
37
+ output(step)
32
38
  end
39
+
40
+ (feature_element["after"] || []).each do |hook|
41
+ after(hook)
42
+ end
43
+
33
44
  (feature_element["examples"] || []).each do |eo|
34
45
  Formatter::Model::Examples.new(comments(eo), tags(eo), keyword(eo), name(eo), description(eo), line(eo), id(eo), examples_rows(eo['rows'])).replay(@formatter)
35
46
  end
@@ -79,12 +90,34 @@ module Gherkin
79
90
  end
80
91
  end
81
92
 
93
+ def before(o)
94
+ m = o['match']
95
+ match = Formatter::Model::Match.new([], location(m))
96
+ r = o['result']
97
+ result = Formatter::Model::Result.new(status(r), duration(r), error_message(r))
98
+ @reporter.before(match, result)
99
+ end
100
+
101
+ def after(o)
102
+ m = o['match']
103
+ match = Formatter::Model::Match.new([], location(m))
104
+ r = o['result']
105
+ result = Formatter::Model::Result.new(status(r), duration(r), error_message(r))
106
+ @reporter.after(match, result)
107
+ end
108
+
82
109
  def embeddings(o)
83
110
  (o['embeddings'] || []).each do |embedding|
84
111
  @reporter.embedding(embedding['mime_type'], Base64::decode64(embedding['data']))
85
112
  end
86
113
  end
87
114
 
115
+ def output(o)
116
+ (o['output'] || []).each do |text|
117
+ @reporter.write(text)
118
+ end
119
+ end
120
+
88
121
  def examples_rows(o)
89
122
  o.map{|row| Formatter::Model::ExamplesTableRow.new(comments(row), row['cells'], row['line'], row['id'])}
90
123
  end
@@ -31,6 +31,14 @@ module Gherkin
31
31
  io.string.strip.should == expected.strip
32
32
  end
33
33
 
34
+ context "invalid mix" do
35
+ it "should throw exception on different filters" do
36
+ lambda do
37
+ verify_filter(['@tag1', /regexp/, 88], 1..61)
38
+ end.should raise_exception(/Inconsistent filters/)
39
+ end
40
+ end
41
+
34
42
  context "tags" do
35
43
  it "should filter on feature tag" do
36
44
  verify_filter(['@tag1'], 1..61)
@@ -12,15 +12,17 @@ module Gherkin
12
12
  f.uri("f.feature")
13
13
  f.feature(Model::Feature.new([], [], "Feature", "ff", "", 1, "ff"))
14
14
  f.scenario(Model::Scenario.new([], [], "Scenario", "ss", "", 2, "ff/ss"))
15
- f.step(Model::Step.new([], "Given ", "g", 3, nil, nil))
16
- f.step(Model::Step.new([], "When ", "w", 4, nil, nil))
17
15
 
16
+ f.step(Model::Step.new([], "Given ", "g", 3, nil, nil))
18
17
  f.match(Model::Match.new([], "def.rb:33"))
19
18
  f.result(Model::Result.new(:passed, 1, nil))
20
19
 
20
+ f.step(Model::Step.new([], "When ", "w", 4, nil, nil))
21
21
  f.match(Model::Match.new([], "def.rb:44"))
22
22
  f.result(Model::Result.new(:passed, 1, nil))
23
23
 
24
+ f.after(Model::Match.new([], "def.rb:55"), Model::Result.new(:passed, 22, nil))
25
+
24
26
  f.eof
25
27
  f.done
26
28
 
@@ -66,6 +68,17 @@ module Gherkin
66
68
  "duration": 1
67
69
  }
68
70
  }
71
+ ],
72
+ "after": [
73
+ {
74
+ "match":{
75
+ "location":"def.rb:55"
76
+ },
77
+ "result":{
78
+ "status":"passed",
79
+ "duration": 22
80
+ }
81
+ }
69
82
  ]
70
83
  }
71
84
  ]
@@ -79,55 +79,93 @@ module Gherkin
79
79
 
80
80
  it "should parse feature with match, result and embedding" do
81
81
  check_json(%{
82
- [
83
- {
84
- "id": "one",
85
- "uri": "test.feature",
86
- "tags": [
82
+ [
87
83
  {
88
- "name": "@foo",
89
- "line": 22
90
- }
91
- ],
92
- "keyword": "Feature",
93
- "name": "One",
94
- "description": "",
95
- "line": 3,
96
- "elements": [
97
- {
98
- "id": "one/a-scenario",
99
- "type": "scenario",
100
- "steps": [
101
- {
102
- "keyword": "Given ",
103
- "name": "a passing step",
104
- "line": 6,
105
- "match": {
106
- "arguments": [
107
- {
108
- "offset": 22,
109
- "val": "cukes"
110
- }
111
- ],
112
- "location": "features/step_definitions/steps.rb:1"
113
- },
114
- "result": {
115
- "status": "failed",
116
- "error_message": "You suck",
117
- "duration": -1
118
- },
119
- "embeddings": [
84
+ "id":"one",
85
+ "uri":"test.feature",
86
+ "tags":[
87
+ {
88
+ "name":"@foo",
89
+ "line":22
90
+ }
91
+ ],
92
+ "keyword":"Feature",
93
+ "name":"One",
94
+ "description":"",
95
+ "line":3,
96
+ "elements":[
120
97
  {
121
- "mime_type": "text/plain",
122
- "data": "Tm8sIEknbSBub3QgaW50ZXJlc3RlZCBpbiBkZXZlbG9waW5nIGEgcG93ZXJmdWwgYnJhaW4uIEFsbCBJJ20gYWZ0ZXIgaXMganVzdCBhIG1lZGlvY3JlIGJyYWluLCBzb21ldGhpbmcgbGlrZSB0aGUgUHJlc2lkZW50IG9mIHRoZSBBbWVyaWNhbiBUZWxlcGhvbmUgYW5kIFRlbGVncmFwaCBDb21wYW55Lg=="
98
+ "id":"one/a-scenario",
99
+ "type":"scenario",
100
+ "before": [
101
+ {
102
+ "match":{
103
+ "location":"features/step_definitions/hooks.rb:1"
104
+ },
105
+ "result":{
106
+ "status":"passed",
107
+ "error_message":"Passed hook",
108
+ "duration": 3
109
+ }
110
+ },
111
+ {
112
+ "match":{
113
+ "location":"features/step_definitions/hooks.rb:2"
114
+ },
115
+ "result":{
116
+ "status":"failed",
117
+ "error_message":"Failed hook",
118
+ "duration": 22
119
+ }
120
+ }
121
+ ],
122
+ "steps":[
123
+ {
124
+ "keyword":"Given ",
125
+ "name":"a passing step",
126
+ "line":6,
127
+ "match":{
128
+ "arguments":[
129
+ {
130
+ "offset":22,
131
+ "val":"cukes"
132
+ }
133
+ ],
134
+ "location":"features/step_definitions/steps.rb:1"
135
+ },
136
+ "result":{
137
+ "status":"failed",
138
+ "error_message":"You suck",
139
+ "duration":-1
140
+ },
141
+ "embeddings":[
142
+ {
143
+ "mime_type":"text/plain",
144
+ "data":"Tm8sIEknbSBub3QgaW50ZXJlc3RlZCBpbiBkZXZlbG9waW5nIGEgcG93ZXJmdWwgYnJhaW4uIEFsbCBJJ20gYWZ0ZXIgaXMganVzdCBhIG1lZGlvY3JlIGJyYWluLCBzb21ldGhpbmcgbGlrZSB0aGUgUHJlc2lkZW50IG9mIHRoZSBBbWVyaWNhbiBUZWxlcGhvbmUgYW5kIFRlbGVncmFwaCBDb21wYW55Lg=="
145
+ }
146
+ ],
147
+ "output":[
148
+ "Hello",
149
+ "World"
150
+ ]
151
+ }
152
+ ],
153
+ "after": [
154
+ {
155
+ "match":{
156
+ "location":"features/step_definitions/hooks.rb:3"
157
+ },
158
+ "result":{
159
+ "status":"failed",
160
+ "error_message":"Failed After",
161
+ "duration": 22
162
+ }
163
+ }
164
+ ]
123
165
  }
124
- ]
125
- }
126
- ]
166
+ ]
127
167
  }
128
- ]
129
- }
130
- ]
168
+ ]
131
169
  })
132
170
  end
133
171
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gherkin
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.10.0
4
+ version: 2.11.0
5
5
  prerelease:
6
6
  platform: java
7
7
  authors:
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2012-05-07 00:00:00.000000000 Z
14
+ date: 2012-06-08 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: json
@@ -36,7 +36,7 @@ dependencies:
36
36
  requirements:
37
37
  - - ! '>='
38
38
  - !ruby/object:Gem::Version
39
- version: 1.2.0
39
+ version: 1.2.1
40
40
  type: :development
41
41
  prerelease: false
42
42
  version_requirements: !ruby/object:Gem::Requirement
@@ -44,7 +44,7 @@ dependencies:
44
44
  requirements:
45
45
  - - ! '>='
46
46
  - !ruby/object:Gem::Version
47
- version: 1.2.0
47
+ version: 1.2.1
48
48
  - !ruby/object:Gem::Dependency
49
49
  name: rake
50
50
  requirement: !ruby/object:Gem::Requirement
@@ -84,7 +84,7 @@ dependencies:
84
84
  requirements:
85
85
  - - ~>
86
86
  - !ruby/object:Gem::Version
87
- version: 2.9.0
87
+ version: 2.10.0
88
88
  type: :development
89
89
  prerelease: false
90
90
  version_requirements: !ruby/object:Gem::Requirement
@@ -92,7 +92,7 @@ dependencies:
92
92
  requirements:
93
93
  - - ~>
94
94
  - !ruby/object:Gem::Version
95
- version: 2.9.0
95
+ version: 2.10.0
96
96
  - !ruby/object:Gem::Dependency
97
97
  name: rubyzip
98
98
  requirement: !ruby/object:Gem::Requirement
@@ -109,6 +109,22 @@ dependencies:
109
109
  - - ! '>='
110
110
  - !ruby/object:Gem::Version
111
111
  version: 0.9.8
112
+ - !ruby/object:Gem::Dependency
113
+ name: therubyracer
114
+ requirement: !ruby/object:Gem::Requirement
115
+ none: false
116
+ requirements:
117
+ - - ! '>='
118
+ - !ruby/object:Gem::Version
119
+ version: 0.10.1
120
+ type: :development
121
+ prerelease: false
122
+ version_requirements: !ruby/object:Gem::Requirement
123
+ none: false
124
+ requirements:
125
+ - - ! '>='
126
+ - !ruby/object:Gem::Version
127
+ version: 0.10.1
112
128
  - !ruby/object:Gem::Dependency
113
129
  name: yard
114
130
  requirement: !ruby/object:Gem::Requirement
@@ -344,7 +360,7 @@ rubyforge_project:
344
360
  rubygems_version: 1.8.24
345
361
  signing_key:
346
362
  specification_version: 3
347
- summary: gherkin-2.10.0
363
+ summary: gherkin-2.11.0
348
364
  test_files:
349
365
  - features/escaped_pipes.feature
350
366
  - features/feature_parser.feature