gherkin 2.5.4 → 2.6.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,6 @@
1
- {
1
+ {
2
+ "id": "feature-text",
3
+ "uri": "some/nice.feature",
2
4
  "name": "Feature Text",
3
5
  "keyword": "Feature",
4
6
  "description": "In order to test multiline forms",
@@ -20,6 +22,7 @@
20
22
  ]
21
23
  },
22
24
  { "type": "scenario_outline",
25
+ "id": "feature-text/a-scenario-outline",
23
26
  "keyword": "Scenario Outline",
24
27
  "name": "An Scenario Outline",
25
28
  "description": "",
@@ -36,6 +39,7 @@
36
39
  ],
37
40
  "examples": [
38
41
  {
42
+ "id": "feature-text/a-scenario-outline/sweet-example",
39
43
  "name": "Sweet Example",
40
44
  "keyword": "Examples",
41
45
  "description": "",
@@ -52,6 +56,7 @@
52
56
  ]
53
57
  },
54
58
  { "type" : "scenario",
59
+ "id": "feature-text/reading-a-scenario",
55
60
  "keyword": "Scenario",
56
61
  "name" : "Reading a Scenario",
57
62
  "description": "",
@@ -67,6 +72,7 @@
67
72
  ]
68
73
  },
69
74
  { "type" : "scenario",
75
+ "id": "feature-text/reading-a-second-scenario",
70
76
  "keyword": "Scenario",
71
77
  "name" : "Reading a second scenario",
72
78
  "description": "With two lines of text",
@@ -111,6 +117,7 @@
111
117
  ]
112
118
  },
113
119
  { "type" : "scenario",
120
+ "id": "feature-text/hammerzeit",
114
121
  "keyword": "Scenario",
115
122
  "name" : "Hammerzeit",
116
123
  "description": "",
@@ -10,10 +10,10 @@ module Gherkin
10
10
  io = StringIO.new
11
11
  f = JSONFormatter.new(io)
12
12
  f.uri("f.feature")
13
- f.feature(Model::Feature.new([], [], "Feature", "f", "", 1))
14
- f.scenario(Model::Scenario.new([], [], "Feature", "f", "", 2))
15
- f.step(Model::Step.new([], "Given ", "g", 3))
16
- f.step(Model::Step.new([], "When ", "w", 4))
13
+ f.feature(Model::Feature.new([], [], "Feature", "ff", "", 1, "ff"))
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
17
 
18
18
  f.match(Model::Match.new([], "def.rb:33"))
19
19
  f.result(Model::Result.new(:passed, 1, nil))
@@ -22,49 +22,55 @@ module Gherkin
22
22
  f.result(Model::Result.new(:passed, 1, nil))
23
23
 
24
24
  f.eof
25
+ f.close
25
26
 
26
27
  expected = %{
27
- {
28
- "keyword": "Feature",
29
- "name": "f",
30
- "line": 1,
31
- "description": "",
32
- "elements": [
33
- {
34
- "keyword": "Feature",
35
- "name": "f",
36
- "line": 2,
37
- "description": "",
38
- "type": "scenario",
39
- "steps": [
40
- {
41
- "keyword": "Given ",
42
- "name": "g",
43
- "line": 3,
44
- "match": {
45
- "location": "def.rb:33"
28
+ [
29
+ {
30
+ "id": "ff",
31
+ "uri": "f.feature",
32
+ "keyword": "Feature",
33
+ "name": "ff",
34
+ "line": 1,
35
+ "description": "",
36
+ "elements": [
37
+ {
38
+ "id": "ff/ss",
39
+ "keyword": "Scenario",
40
+ "name": "ss",
41
+ "line": 2,
42
+ "description": "",
43
+ "type": "scenario",
44
+ "steps": [
45
+ {
46
+ "keyword": "Given ",
47
+ "name": "g",
48
+ "line": 3,
49
+ "match": {
50
+ "location": "def.rb:33"
51
+ },
52
+ "result": {
53
+ "status": "passed",
54
+ "duration": 1
55
+ }
46
56
  },
47
- "result": {
48
- "status": "passed",
49
- "duration": 1
57
+ {
58
+ "keyword": "When ",
59
+ "name": "w",
60
+ "line": 4,
61
+ "match": {
62
+ "location": "def.rb:44"
63
+ },
64
+ "result": {
65
+ "status": "passed",
66
+ "duration": 1
67
+ }
50
68
  }
51
- },
52
- {
53
- "keyword": "When ",
54
- "name": "w",
55
- "line": 4,
56
- "match": {
57
- "location": "def.rb:44"
58
- },
59
- "result": {
60
- "status": "passed",
61
- "duration": 1
62
- }
63
- }
64
- ]
65
- }
66
- ]
67
- }
69
+ ]
70
+ }
71
+ ]
72
+ }
73
+ ]
68
74
  }
69
75
 
70
76
  JSON.parse(expected).should == JSON.parse(io.string)
@@ -14,12 +14,12 @@ module Gherkin
14
14
 
15
15
  describe Step do
16
16
  it "should provide arguments for outline tokens" do
17
- step = Step.new([], 'Given ', "I have <number> cukes in <whose> belly", 10)
17
+ step = Step.new([], 'Given ', "I have <number> cukes in <whose> belly", 10, nil, nil)
18
18
  step.outline_args.map{|arg| [arg.offset, arg.val]}.should == [[7, "<number>"], [25, "<whose>"]]
19
19
  end
20
20
 
21
21
  it "should provide no arguments when there are no outline tokens" do
22
- step = Step.new([], 'Given ', "I have 33 cukes in my belly", 10)
22
+ step = Step.new([], 'Given ', "I have 33 cukes in my belly", 10, nil, nil)
23
23
  step.outline_args.to_a.should == []
24
24
  end
25
25
  end
@@ -36,11 +36,11 @@ module Gherkin
36
36
 
37
37
  it "should print comments when scenario is longer" do
38
38
  @f.uri("features/foo.feature")
39
- @f.feature(Model::Feature.new([], [], "Feature", "Hello", "World", 1))
39
+ @f.feature(Model::Feature.new([], [], "Feature", "Hello", "World", 1, "hello"))
40
40
 
41
- @f.scenario(Model::Scenario.new([], [], "Scenario", "The scenario", "", 4))
42
- @f.step(Model::Step.new([], "Given ", "some stuff", 5))
43
- @f.step(Model::Step.new([], "When ", "foo", 6))
41
+ @f.scenario(Model::Scenario.new([], [], "Scenario", "The scenario", "", 4, "the-scenario"))
42
+ @f.step(Model::Step.new([], "Given ", "some stuff", 5, nil, nil))
43
+ @f.step(Model::Step.new([], "When ", "foo", 6, nil, nil))
44
44
 
45
45
  @f.match(Model::Match.new([], "features/step_definitions/bar.rb:56"))
46
46
  @f.result(Model::Result.new('passed', 22, nil))
@@ -61,12 +61,12 @@ module Gherkin
61
61
 
62
62
  it "should print comments when step is longer" do
63
63
  @f.uri("features/foo.feature")
64
- @f.feature(Model::Feature.new([], [], "Feature", "Hello", "World", 1))
65
- step = Model::Step.new([], "Given ", "some stuff that is longer", 5)
64
+ @f.feature(Model::Feature.new([], [], "Feature", "Hello", "World", 1, "hello"))
65
+ step = Model::Step.new([], "Given ", "some stuff that is longer", 5, nil, nil)
66
66
  match = Model::Match.new([], "features/step_definitions/bar.rb:56")
67
67
  result = Model::Result.new('passed', 0, nil)
68
68
 
69
- @f.scenario(Model::Scenario.new([], [], "Scenario", "The scenario", "", 4))
69
+ @f.scenario(Model::Scenario.new([], [], "Scenario", "The scenario", "", 4, "the-scenario"))
70
70
  @f.step(step)
71
71
  @f.match(match)
72
72
  @f.result(result)
@@ -82,8 +82,8 @@ module Gherkin
82
82
 
83
83
  it "should highlight arguments for regular steps" do
84
84
  @f.uri("foo.feature")
85
- @f.scenario(Model::Scenario.new([], [], "Scenario", "Lots of cukes", "", 3))
86
- @f.step(Model::Step.new([], "Given ", "I have 999 cukes in my belly", 3))
85
+ @f.scenario(Model::Scenario.new([], [], "Scenario", "Lots of cukes", "", 3, "lots-of-cukes"))
86
+ @f.step(Model::Step.new([], "Given ", "I have 999 cukes in my belly", 3, nil, nil))
87
87
  @f.match(Model::Match.new([Gherkin::Formatter::Argument.new(7, '999')], nil))
88
88
  @f.result(Model::Result.new('passed', 6, nil))
89
89
 
@@ -150,7 +150,7 @@ Feature: Feature Description
150
150
  it "should escape backslashes and pipes" do
151
151
  io = StringIO.new
152
152
  f = Gherkin::Formatter::PrettyFormatter.new(io, true, false)
153
- f.__send__(:table, [Gherkin::Formatter::Model::Row.new([], ['|', '\\'], 1)])
153
+ f.__send__(:table, [Gherkin::Formatter::Model::DataTableRow.new([], ['|', '\\'], 1)])
154
154
  io.string.should == ' | \\| | \\\\ |' + "\n"
155
155
  end
156
156
  end
@@ -1,4 +1,5 @@
1
1
  #encoding: utf-8
2
+ require 'stringio'
2
3
  require 'spec_helper'
3
4
  require 'gherkin/json_parser'
4
5
  require 'gherkin/formatter/json_formatter'
@@ -10,100 +11,115 @@ module Gherkin
10
11
  io = StringIO.new
11
12
  f = Formatter::JSONFormatter.new(io)
12
13
  p = JSONParser.new(f, f)
13
- p.parse(json, 'unknown.json', 0)
14
+ p.parse(json)
15
+ f.close
14
16
  expected = JSON.parse(json)
15
17
  actual = JSON.parse(io.string)
16
18
  actual.should == expected
17
19
  end
18
20
 
19
21
  it "should parse a barely empty feature" do
20
- check_json(%{{
21
- "keyword": "Feature",
22
- "name": "One",
23
- "description": "",
24
- "line" : 3
25
- }})
22
+ check_json(%{[
23
+ {
24
+ "id": "one",
25
+ "uri": "test.feature",
26
+ "keyword": "Feature",
27
+ "name": "One",
28
+ "description": "",
29
+ "line" : 3
30
+ }
31
+ ]})
26
32
  end
27
33
 
28
34
  it "should parse feature with tags and one scenario" do
29
- check_json(%{{
30
- "tags": [
31
- {
32
- "name": "@foo",
33
- "line": 22
34
- }
35
- ],
36
- "keyword": "Feature",
37
- "name": "One",
38
- "description": "",
39
- "line": 3,
40
- "elements": [
41
- {
42
- "type": "scenario",
43
- "steps": [
44
- {
45
- "name": "Hello",
46
- "rows": [
47
- {
48
- "cells": ["foo", "bar"]
49
- }
50
- ]
51
- }
52
- ]
53
- }
54
- ]
55
- }})
35
+ check_json(%{[
36
+ {
37
+ "id": "one",
38
+ "uri": "test.feature",
39
+ "tags": [
40
+ {
41
+ "name": "@foo",
42
+ "line": 22
43
+ }
44
+ ],
45
+ "keyword": "Feature",
46
+ "name": "One",
47
+ "description": "",
48
+ "line": 3,
49
+ "elements": [
50
+ {
51
+ "id": "one/two",
52
+ "type": "scenario",
53
+ "steps": [
54
+ {
55
+ "name": "Hello",
56
+ "rows": [
57
+ {
58
+ "cells": ["foo", "bar"]
59
+ }
60
+ ]
61
+ }
62
+ ]
63
+ }
64
+ ]
65
+ }
66
+ ]})
56
67
  end
57
68
 
58
69
  it "should parse feature with match, result and embedding" do
59
- check_json(%{{
60
- "tags": [
61
- {
62
- "name": "@foo",
63
- "line": 22
64
- }
65
- ],
66
- "keyword": "Feature",
67
- "name": "One",
68
- "description": "",
69
- "line": 3,
70
- "elements": [
71
- {
72
- "type": "scenario",
73
- "steps": [
74
- {
75
- "keyword": "Given ",
76
- "name": "a passing step",
77
- "line": 6,
78
- "match": {
79
- "arguments": [
70
+ check_json(%{[
71
+ {
72
+ "id": "one",
73
+ "uri": "test.feature",
74
+ "tags": [
75
+ {
76
+ "name": "@foo",
77
+ "line": 22
78
+ }
79
+ ],
80
+ "keyword": "Feature",
81
+ "name": "One",
82
+ "description": "",
83
+ "line": 3,
84
+ "elements": [
85
+ {
86
+ "id": "one/a-scenario",
87
+ "type": "scenario",
88
+ "steps": [
89
+ {
90
+ "keyword": "Given ",
91
+ "name": "a passing step",
92
+ "line": 6,
93
+ "match": {
94
+ "arguments": [
95
+ {
96
+ "offset": 22,
97
+ "val": "cukes"
98
+ }
99
+ ],
100
+ "location": "features/step_definitions/steps.rb:1"
101
+ },
102
+ "result": {
103
+ "status": "failed",
104
+ "error_message": "You suck",
105
+ "duration": -1
106
+ },
107
+ "embeddings": [
80
108
  {
81
- "offset": 22,
82
- "val": "cukes"
109
+ "mime_type": "text/plain",
110
+ "data": "Tm8sIEknbSBub3QgaW50ZXJlc3RlZCBpbiBkZXZlbG9waW5nIGEgcG93ZXJmdWwgYnJhaW4uIEFsbCBJJ20gYWZ0ZXIgaXMganVzdCBhIG1lZGlvY3JlIGJyYWluLCBzb21ldGhpbmcgbGlrZSB0aGUgUHJlc2lkZW50IG9mIHRoZSBBbWVyaWNhbiBUZWxlcGhvbmUgYW5kIFRlbGVncmFwaCBDb21wYW55Lg=="
83
111
  }
84
- ],
85
- "location": "features/step_definitions/steps.rb:1"
86
- },
87
- "result": {
88
- "status": "failed",
89
- "error_message": "You suck",
90
- "duration": -1
91
- },
92
- "embeddings": [
93
- {
94
- "mime_type": "text/plain",
95
- "data": "Tm8sIEknbSBub3QgaW50ZXJlc3RlZCBpbiBkZXZlbG9waW5nIGEgcG93ZXJmdWwgYnJhaW4uIEFsbCBJJ20gYWZ0ZXIgaXMganVzdCBhIG1lZGlvY3JlIGJyYWluLCBzb21ldGhpbmcgbGlrZSB0aGUgUHJlc2lkZW50IG9mIHRoZSBBbWVyaWNhbiBUZWxlcGhvbmUgYW5kIFRlbGVncmFwaCBDb21wYW55Lg=="
96
- }
97
- ]
98
- }
99
- ]
100
- }
101
- ]
102
- }})
112
+ ]
113
+ }
114
+ ]
115
+ }
116
+ ]
117
+ }
118
+ ]})
103
119
  end
104
120
 
105
121
  it "shoud parse a complex feature" do
106
- check_json(fixture("complex.json"))
122
+ check_json('[' + fixture("complex.json") + ']')
107
123
  end
108
124
  end
109
125
  end
@@ -12,9 +12,6 @@ module Gherkin
12
12
  # We can't use method_missing - therubyracer isn't able to invoke methods like that.
13
13
  [:comment, :tag, :feature, :background, :scenario, :scenario_outline, :examples, :step, :doc_string, :row, :eof, :uri, :syntax_error].each do |event|
14
14
  define_method(event) do |*args|
15
- event = :scenario_outline if event == :scenarioOutline # Special Java Lexer handling
16
- event = :doc_string if event == :docString # Special Java Lexer handling
17
- event = :syntax_error if event == :syntaxError # Special Java Lexer handling
18
15
  args = rubify(args)
19
16
  args = sexpify(args)
20
17
  @sexps << [event] + args
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.5.4
4
+ version: 2.6.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,11 +11,11 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2011-10-20 00:00:00.000000000Z
14
+ date: 2011-10-30 00:00:00.000000000Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: rake-compiler
18
- requirement: &2168456760 !ruby/object:Gem::Requirement
18
+ requirement: &2156601980 !ruby/object:Gem::Requirement
19
19
  none: false
20
20
  requirements:
21
21
  - - ! '>='
@@ -23,10 +23,10 @@ dependencies:
23
23
  version: 0.7.9
24
24
  type: :development
25
25
  prerelease: false
26
- version_requirements: *2168456760
26
+ version_requirements: *2156601980
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: json
29
- requirement: &2164530600 !ruby/object:Gem::Requirement
29
+ requirement: &2156580920 !ruby/object:Gem::Requirement
30
30
  none: false
31
31
  requirements:
32
32
  - - ! '>='
@@ -34,21 +34,21 @@ dependencies:
34
34
  version: 1.4.6
35
35
  type: :runtime
36
36
  prerelease: false
37
- version_requirements: *2164530600
37
+ version_requirements: *2156580920
38
38
  - !ruby/object:Gem::Dependency
39
39
  name: cucumber
40
- requirement: &2164529340 !ruby/object:Gem::Requirement
40
+ requirement: &2156579660 !ruby/object:Gem::Requirement
41
41
  none: false
42
42
  requirements:
43
43
  - - ! '>='
44
44
  - !ruby/object:Gem::Version
45
- version: 1.1.0
45
+ version: 1.1.1
46
46
  type: :development
47
47
  prerelease: false
48
- version_requirements: *2164529340
48
+ version_requirements: *2156579660
49
49
  - !ruby/object:Gem::Dependency
50
50
  name: rake
51
- requirement: &2164527320 !ruby/object:Gem::Requirement
51
+ requirement: &2156533700 !ruby/object:Gem::Requirement
52
52
  none: false
53
53
  requirements:
54
54
  - - ! '>='
@@ -56,10 +56,10 @@ dependencies:
56
56
  version: 0.9.2
57
57
  type: :development
58
58
  prerelease: false
59
- version_requirements: *2164527320
59
+ version_requirements: *2156533700
60
60
  - !ruby/object:Gem::Dependency
61
61
  name: bundler
62
- requirement: &2164517460 !ruby/object:Gem::Requirement
62
+ requirement: &2156525300 !ruby/object:Gem::Requirement
63
63
  none: false
64
64
  requirements:
65
65
  - - ! '>='
@@ -67,21 +67,21 @@ dependencies:
67
67
  version: 1.0.21
68
68
  type: :development
69
69
  prerelease: false
70
- version_requirements: *2164517460
70
+ version_requirements: *2156525300
71
71
  - !ruby/object:Gem::Dependency
72
72
  name: rspec
73
- requirement: &2164515180 !ruby/object:Gem::Requirement
73
+ requirement: &2156523400 !ruby/object:Gem::Requirement
74
74
  none: false
75
75
  requirements:
76
76
  - - ! '>='
77
77
  - !ruby/object:Gem::Version
78
- version: 2.6.0
78
+ version: 2.7.0
79
79
  type: :development
80
80
  prerelease: false
81
- version_requirements: *2164515180
81
+ version_requirements: *2156523400
82
82
  - !ruby/object:Gem::Dependency
83
83
  name: therubyracer
84
- requirement: &2164507340 !ruby/object:Gem::Requirement
84
+ requirement: &2156522260 !ruby/object:Gem::Requirement
85
85
  none: false
86
86
  requirements:
87
87
  - - ! '>='
@@ -89,10 +89,10 @@ dependencies:
89
89
  version: 0.9.8
90
90
  type: :development
91
91
  prerelease: false
92
- version_requirements: *2164507340
92
+ version_requirements: *2156522260
93
93
  - !ruby/object:Gem::Dependency
94
94
  name: yard
95
- requirement: &2164490040 !ruby/object:Gem::Requirement
95
+ requirement: &2156520480 !ruby/object:Gem::Requirement
96
96
  none: false
97
97
  requirements:
98
98
  - - ! '>='
@@ -100,10 +100,10 @@ dependencies:
100
100
  version: 0.7.2
101
101
  type: :development
102
102
  prerelease: false
103
- version_requirements: *2164490040
103
+ version_requirements: *2156520480
104
104
  - !ruby/object:Gem::Dependency
105
105
  name: rdiscount
106
- requirement: &2164467380 !ruby/object:Gem::Requirement
106
+ requirement: &2156517340 !ruby/object:Gem::Requirement
107
107
  none: false
108
108
  requirements:
109
109
  - - ! '>='
@@ -111,10 +111,10 @@ dependencies:
111
111
  version: 1.6.8
112
112
  type: :development
113
113
  prerelease: false
114
- version_requirements: *2164467380
114
+ version_requirements: *2156517340
115
115
  - !ruby/object:Gem::Dependency
116
116
  name: term-ansicolor
117
- requirement: &2164465240 !ruby/object:Gem::Requirement
117
+ requirement: &2156511840 !ruby/object:Gem::Requirement
118
118
  none: false
119
119
  requirements:
120
120
  - - ! '>='
@@ -122,10 +122,10 @@ dependencies:
122
122
  version: 1.0.6
123
123
  type: :development
124
124
  prerelease: false
125
- version_requirements: *2164465240
125
+ version_requirements: *2156511840
126
126
  - !ruby/object:Gem::Dependency
127
127
  name: builder
128
- requirement: &2164464040 !ruby/object:Gem::Requirement
128
+ requirement: &2156509760 !ruby/object:Gem::Requirement
129
129
  none: false
130
130
  requirements:
131
131
  - - ! '>='
@@ -133,7 +133,7 @@ dependencies:
133
133
  version: 2.1.2
134
134
  type: :development
135
135
  prerelease: false
136
- version_requirements: *2164464040
136
+ version_requirements: *2156509760
137
137
  description: A fast Gherkin lexer/parser based on the Ragel State Machine Compiler.
138
138
  email: cukes@googlegroups.com
139
139
  executables: []
@@ -478,7 +478,7 @@ rubyforge_project:
478
478
  rubygems_version: 1.8.10
479
479
  signing_key:
480
480
  specification_version: 3
481
- summary: gherkin-2.5.4
481
+ summary: gherkin-2.6.0
482
482
  test_files:
483
483
  - features/escaped_pipes.feature
484
484
  - features/feature_parser.feature