gherkin 1.0.30-universal-dotnet → 2.0.0-universal-dotnet
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.
- data/.rspec +1 -0
- data/History.txt +19 -0
- data/Rakefile +4 -4
- data/VERSION.yml +2 -2
- data/features/feature_parser.feature +11 -0
- data/features/json_formatter.feature +238 -0
- data/features/pretty_formatter.feature +9 -0
- data/features/step_definitions/gherkin_steps.rb +1 -1
- data/features/step_definitions/json_formatter_steps.rb +32 -0
- data/features/step_definitions/pretty_formatter_steps.rb +24 -23
- data/features/support/env.rb +3 -3
- data/lib/gherkin/formatter/json_formatter.rb +82 -0
- data/lib/gherkin/formatter/pretty_formatter.rb +73 -78
- data/lib/gherkin/i18n.rb +22 -18
- data/lib/gherkin/i18n.yml +9 -9
- data/lib/gherkin/i18n_lexer.rb +2 -2
- data/lib/gherkin/parser/event.rb +6 -6
- data/lib/gherkin/parser/filter_listener.rb +5 -1
- data/lib/gherkin/parser/formatter_listener.rb +113 -0
- data/lib/gherkin/parser/json_parser.rb +102 -0
- data/lib/gherkin/parser/parser.rb +10 -2
- data/lib/gherkin/parser/row.rb +15 -0
- data/lib/gherkin/rubify.rb +2 -0
- data/lib/gherkin/tools/files.rb +1 -1
- data/lib/gherkin/tools/reformat.rb +1 -2
- data/lib/gherkin/tools/stats.rb +1 -1
- data/lib/gherkin/tools/stats_listener.rb +5 -5
- data/ragel/lexer.c.rl.erb +41 -12
- data/ragel/lexer.java.rl.erb +26 -17
- data/ragel/lexer.rb.rl.erb +10 -5
- data/ragel/lexer_common.rl.erb +6 -6
- data/spec/gherkin/c_lexer_spec.rb +2 -2
- data/spec/gherkin/fixtures/complex.js +105 -0
- data/spec/gherkin/formatter/argument_spec.rb +3 -3
- data/spec/gherkin/formatter/colors_spec.rb +3 -4
- data/spec/gherkin/formatter/pretty_formatter_spec.rb +21 -50
- data/spec/gherkin/i18n_lexer_spec.rb +6 -6
- data/spec/gherkin/i18n_spec.rb +16 -9
- data/spec/gherkin/java_lexer_spec.rb +1 -2
- data/spec/gherkin/output_stream_string_io.rb +24 -0
- data/spec/gherkin/parser/filter_listener_spec.rb +16 -9
- data/spec/gherkin/parser/formatter_listener_spec.rb +134 -0
- data/spec/gherkin/parser/json_parser_spec.rb +129 -0
- data/spec/gherkin/parser/parser_spec.rb +9 -9
- data/spec/gherkin/parser/tag_expression_spec.rb +8 -8
- data/spec/gherkin/rb_lexer_spec.rb +1 -1
- data/spec/gherkin/sexp_recorder.rb +21 -1
- data/spec/gherkin/shared/{lexer_spec.rb → lexer_group.rb} +172 -102
- data/spec/gherkin/shared/{py_string_spec.rb → py_string_group.rb} +21 -17
- data/spec/gherkin/shared/{row_spec.rb → row_group.rb} +36 -19
- data/spec/gherkin/shared/{tags_spec.rb → tags_group.rb} +13 -9
- data/spec/spec_helper.rb +18 -38
- data/tasks/bench.rake +3 -3
- data/tasks/compile.rake +13 -14
- data/tasks/rspec.rake +6 -11
- metadata +42 -28
- data/features/pretty_printer.feature +0 -14
- data/spec/gherkin/csharp_lexer_spec.rb +0 -20
data/spec/gherkin/i18n_spec.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
#encoding: utf-8
|
2
|
-
require
|
2
|
+
require 'spec_helper'
|
3
3
|
|
4
4
|
module Gherkin
|
5
5
|
module Lexer
|
@@ -9,16 +9,17 @@ module Gherkin
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def scan_file(lexer, file)
|
12
|
-
lexer.scan(File.new(File.dirname(__FILE__) + "/fixtures/" + file).read)
|
12
|
+
lexer.scan(File.new(File.dirname(__FILE__) + "/fixtures/" + file).read, file, 0)
|
13
13
|
end
|
14
14
|
|
15
15
|
it "should recognize keywords in the language of the lexer" do
|
16
16
|
lexer = Gherkin::I18nLexer.new(@listener, false)
|
17
17
|
scan_file(lexer, "i18n_no.feature")
|
18
18
|
@listener.to_sexp.should == [
|
19
|
+
[:location, "i18n_no.feature", 0],
|
19
20
|
[:comment, "#language:no", 1],
|
20
|
-
[:feature, "Egenskap", "i18n support", 2],
|
21
|
-
[:scenario, "Scenario", "Parsing many languages", 4],
|
21
|
+
[:feature, "Egenskap", "i18n support", "", 2],
|
22
|
+
[:scenario, "Scenario", "Parsing many languages", "", 4],
|
22
23
|
[:step, "Gitt ", "Gherkin supports many languages", 5],
|
23
24
|
[:step, "Når ", "Norwegian keywords are parsed", 6],
|
24
25
|
[:step, "Så ", "they should be recognized", 7],
|
@@ -30,9 +31,10 @@ module Gherkin
|
|
30
31
|
lexer = Gherkin::I18nLexer.new(@listener, false)
|
31
32
|
scan_file(lexer, "i18n_zh-CN.feature")
|
32
33
|
@listener.to_sexp.should == [
|
34
|
+
[:location, "i18n_zh-CN.feature", 0],
|
33
35
|
[:comment, "#language:zh-CN", 1],
|
34
|
-
[:feature, "功能", "加法", 2],
|
35
|
-
[:scenario, "场景", "两个数相加", 4],
|
36
|
+
[:feature, "功能", "加法", "", 2],
|
37
|
+
[:scenario, "场景", "两个数相加", "", 4],
|
36
38
|
[:step, "假如", "我已经在计算器里输入6", 5],
|
37
39
|
[:step, "而且", "我已经在计算器里输入7", 6],
|
38
40
|
[:step, "当", "我按相加按钮", 7],
|
@@ -45,15 +47,16 @@ module Gherkin
|
|
45
47
|
lexer = Gherkin::I18nLexer.new(@listener, false)
|
46
48
|
scan_file(lexer, "i18n_fr.feature")
|
47
49
|
@listener.to_sexp.should == [
|
50
|
+
[:location, "i18n_fr.feature", 0],
|
48
51
|
[:comment, "#language:fr", 1],
|
49
|
-
[:feature, "Fonctionnalité", "Addition", 2],
|
50
|
-
[:scenario_outline, "Plan du scénario", "Addition de produits dérivés", 3],
|
52
|
+
[:feature, "Fonctionnalité", "Addition", "", 2],
|
53
|
+
[:scenario_outline, "Plan du scénario", "Addition de produits dérivés", "", 3],
|
51
54
|
[:step, "Soit ", "une calculatrice", 4],
|
52
55
|
[:step, "Etant donné ", "qu'on tape <a>", 5],
|
53
56
|
[:step, "Et ", "qu'on tape <b>", 6],
|
54
57
|
[:step, "Lorsqu'", "on tape additionner", 7],
|
55
58
|
[:step, "Alors ", "le résultat doit être <somme>", 8],
|
56
|
-
[:examples, "Exemples", "", 10],
|
59
|
+
[:examples, "Exemples", "", "", 10],
|
57
60
|
[:row, %w{a b somme}, 11],
|
58
61
|
[:row, %w{2 2 4}, 12],
|
59
62
|
[:row, %w{2 3 5}, 13],
|
@@ -68,6 +71,10 @@ module Gherkin
|
|
68
71
|
end
|
69
72
|
end
|
70
73
|
|
74
|
+
it "should report keyword regexp" do
|
75
|
+
Gherkin::I18n.keyword_regexp(:step).should =~ /\|Quando \|Quand \|Quan \|Pryd \|Pokud \|/
|
76
|
+
end
|
77
|
+
|
71
78
|
unless defined?(JRUBY_VERSION)
|
72
79
|
it "should print available languages" do
|
73
80
|
("\n" + Gherkin::I18n.language_table).should == %{
|
@@ -0,0 +1,24 @@
|
|
1
|
+
if defined?(JRUBY_VERSION)
|
2
|
+
class OutputStreamStringIO < Java.java.io.ByteArrayOutputStream
|
3
|
+
def write(what)
|
4
|
+
if String === what
|
5
|
+
super(Java.java.lang.String.new(what).getBytes("UTF-8"))
|
6
|
+
else
|
7
|
+
super(what)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def string
|
12
|
+
toString("UTF-8")
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
require 'stringio'
|
17
|
+
class StringIO
|
18
|
+
class << self
|
19
|
+
def new
|
20
|
+
OutputStreamStringIO.new
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
-
require
|
2
|
+
require 'spec_helper'
|
3
3
|
require 'gherkin/parser/filter_listener'
|
4
|
+
require 'gherkin/parser/formatter_listener'
|
4
5
|
require 'gherkin/formatter/pretty_formatter'
|
5
6
|
require 'stringio'
|
6
7
|
|
@@ -11,8 +12,12 @@ module Gherkin
|
|
11
12
|
class LineListener
|
12
13
|
attr_reader :lines
|
13
14
|
|
15
|
+
def location(uri, offset)
|
16
|
+
end
|
17
|
+
|
14
18
|
def method_missing(*sexp_args)
|
15
19
|
@lines ||= []
|
20
|
+
raise "Hmm" if sexp_args == [:eof, []]
|
16
21
|
@lines << sexp_args[-1]
|
17
22
|
end
|
18
23
|
end
|
@@ -25,16 +30,17 @@ module Gherkin
|
|
25
30
|
|
26
31
|
def verify_output(expected_output, filters)
|
27
32
|
io = StringIO.new
|
28
|
-
|
29
|
-
|
30
|
-
|
33
|
+
formatter = Gherkin::Formatter::PrettyFormatter.new(io, true)
|
34
|
+
listener = Gherkin::Parser::FormatterListener.new(formatter)
|
35
|
+
scan(listener, filters)
|
36
|
+
io.string.should == expected_output
|
31
37
|
end
|
32
38
|
|
33
39
|
def scan(listener, filters)
|
34
|
-
filter_listener = FilterListener.new(listener, filters)
|
40
|
+
filter_listener = Gherkin::Parser::FilterListener.new(listener, filters)
|
35
41
|
parser = Gherkin::Parser::Parser.new(filter_listener, true, "root")
|
36
42
|
lexer = Gherkin::I18nLexer.new(parser, true)
|
37
|
-
lexer.scan(@input)
|
43
|
+
lexer.scan(@input, "test.feature", 0)
|
38
44
|
end
|
39
45
|
|
40
46
|
context "Scenario" do
|
@@ -195,8 +201,8 @@ Feature: 2
|
|
195
201
|
|
196
202
|
context "Scenario Outline" do
|
197
203
|
before do
|
198
|
-
@input = %{Feature:
|
199
|
-
|
204
|
+
@input = %{Feature: Fname
|
205
|
+
Fdesc
|
200
206
|
@tag3
|
201
207
|
Scenario Outline: 4
|
202
208
|
Given <foo> 5
|
@@ -252,7 +258,8 @@ Feature: 2
|
|
252
258
|
end
|
253
259
|
|
254
260
|
it "should replay itself properly" do
|
255
|
-
filtered = %{Feature:
|
261
|
+
filtered = %{Feature: Fname
|
262
|
+
Fdesc
|
256
263
|
|
257
264
|
@tag3
|
258
265
|
Scenario Outline: 4
|
@@ -0,0 +1,134 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'gherkin/parser/formatter_listener'
|
3
|
+
require 'gherkin/parser/parser'
|
4
|
+
require 'gherkin/parser/row'
|
5
|
+
require 'gherkin/i18n_lexer'
|
6
|
+
require 'stringio'
|
7
|
+
|
8
|
+
module Gherkin
|
9
|
+
module Parser
|
10
|
+
describe FormatterListener do
|
11
|
+
before do
|
12
|
+
@formatter = Gherkin::SexpRecorder.new
|
13
|
+
@fl = Gherkin::Parser::FormatterListener.new(@formatter)
|
14
|
+
@lexer = Gherkin::I18nLexer.new(Gherkin::Parser::Parser.new(@fl))
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should pass tags to #feature method" do
|
18
|
+
@fl.tag("@hello", 1)
|
19
|
+
@fl.feature("Feature", "awesome", "description", 2)
|
20
|
+
@fl.eof
|
21
|
+
|
22
|
+
@formatter.to_sexp.should == [
|
23
|
+
[:feature, [], ["@hello"], "Feature", "awesome", "description", nil],
|
24
|
+
[:eof]
|
25
|
+
]
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should pass comments to #feature method" do
|
29
|
+
@fl.comment("# comment", 1)
|
30
|
+
@fl.feature("Feature", "awesome", "description", 2)
|
31
|
+
@fl.eof
|
32
|
+
|
33
|
+
@formatter.to_sexp.should == [
|
34
|
+
[:feature, ["# comment"], [], "Feature", "awesome", "description", nil],
|
35
|
+
[:eof]
|
36
|
+
]
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should pass comments and tags to #feature and #scenario methods" do
|
40
|
+
@fl.comment("# one", 1)
|
41
|
+
@fl.tag("@two", 2)
|
42
|
+
@fl.feature("Feature", "three", "feature description", 3)
|
43
|
+
@fl.comment("# four", 4)
|
44
|
+
@fl.tag("@five", 5)
|
45
|
+
@fl.scenario("Scenario", "six", "scenario description", 6)
|
46
|
+
@fl.eof
|
47
|
+
|
48
|
+
@formatter.to_sexp.should == [
|
49
|
+
[:feature, ["# one"], ["@two"], "Feature", "three", "feature description", nil],
|
50
|
+
[:scenario, ["# four"], ["@five"], "Scenario", "six", "scenario description", 6],
|
51
|
+
[:eof]
|
52
|
+
]
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should replay step table" do
|
56
|
+
@fl.step("Given ", "foo", 10)
|
57
|
+
@fl.row(['yo'], 11)
|
58
|
+
@fl.comment("# Hello", 12)
|
59
|
+
@fl.comment("# World", 13)
|
60
|
+
@fl.row(['bro'], 14)
|
61
|
+
@fl.eof
|
62
|
+
|
63
|
+
@formatter.to_sexp.should == [
|
64
|
+
[:step, [], "Given ", "foo", 10, [
|
65
|
+
{"line"=>11, "comments"=>[], "cells"=>["yo"]},
|
66
|
+
{"line"=>14, "comments"=>["# Hello", "# World"], "cells"=>["bro"]}
|
67
|
+
], nil, nil, nil, nil],
|
68
|
+
[:eof]
|
69
|
+
]
|
70
|
+
end
|
71
|
+
|
72
|
+
it "should format an entire feature" do
|
73
|
+
@lexer.scan(File.new(File.dirname(__FILE__) + "/../fixtures/complex.feature").read, "complex.feature", 0)
|
74
|
+
@formatter.to_sexp.should == [
|
75
|
+
[:feature, ["#Comment on line 1", "#Comment on line 2"], ["@tag1", "@tag2"],
|
76
|
+
"Feature",
|
77
|
+
"Feature Text",
|
78
|
+
"In order to test multiline forms\nAs a ragel writer\nI need to check for complex combinations",
|
79
|
+
"complex.feature"],
|
80
|
+
[:background, ["#Comment on line 9", "#Comment on line 11"], "Background", "", "", 13],
|
81
|
+
[:step, [], "Given ", "this is a background step", 14, nil, nil, nil, nil, nil],
|
82
|
+
[:step, [], "And ", "this is another one", 15, nil, nil, nil, nil, nil],
|
83
|
+
[:scenario, [], ["@tag3", "@tag4"], "Scenario", "Reading a Scenario", "", 18],
|
84
|
+
[:step, [], "Given ", "there is a step", 19, nil, nil, nil, nil, nil],
|
85
|
+
[:step, [], "But ", "not another step", 20, nil, nil, nil, nil, nil],
|
86
|
+
[:scenario, [], ["@tag3"], "Scenario", "Reading a second scenario", "With two lines of text", 23],
|
87
|
+
[:step, ["#Comment on line 24"], "Given ", "a third step with a table", 26, [
|
88
|
+
{
|
89
|
+
"comments" => [],
|
90
|
+
"line" => 27,
|
91
|
+
"cells" => ["a", "b"]
|
92
|
+
},
|
93
|
+
{
|
94
|
+
"comments" => [],
|
95
|
+
"line" => 28,
|
96
|
+
"cells" => ["c", "d"]
|
97
|
+
},
|
98
|
+
{
|
99
|
+
"comments" => [],
|
100
|
+
"line" => 29,
|
101
|
+
"cells" => ["e", "f"]
|
102
|
+
} ], nil, nil, nil, nil],
|
103
|
+
[:step, [], "And ", "I am still testing things", 30, [
|
104
|
+
{
|
105
|
+
"comments" => [],
|
106
|
+
"line" => 31,
|
107
|
+
"cells" => ["g", "h"]
|
108
|
+
},
|
109
|
+
{
|
110
|
+
"comments" => [],
|
111
|
+
"line" => 32,
|
112
|
+
"cells" => ["e", "r"]
|
113
|
+
},
|
114
|
+
{
|
115
|
+
"comments" => [],
|
116
|
+
"line" => 33,
|
117
|
+
"cells" => ["k", "i"]
|
118
|
+
},
|
119
|
+
{
|
120
|
+
"comments" => [],
|
121
|
+
"line" => 34,
|
122
|
+
"cells" => ["n", ""]
|
123
|
+
} ], nil, nil, nil, nil],
|
124
|
+
[:step, [], "And ", "I am done testing these tables", 35, nil, nil, nil, nil, nil],
|
125
|
+
[:step, ["#Comment on line 29"], "Then ", "I am happy", 37, nil, nil, nil, nil, nil],
|
126
|
+
[:scenario, [], [], "Scenario", "Hammerzeit", "", 39],
|
127
|
+
[:step, [], "Given ", "All work and no play", 40, "Makes Homer something something\nAnd something else", nil, nil, nil, nil],
|
128
|
+
[:step, [], "Then ", "crazy", 45, nil, nil, nil, nil, nil],
|
129
|
+
[:eof]
|
130
|
+
]
|
131
|
+
end
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
@@ -0,0 +1,129 @@
|
|
1
|
+
#encoding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
require 'gherkin/parser/json_parser'
|
4
|
+
|
5
|
+
module Gherkin
|
6
|
+
module Parser
|
7
|
+
describe JSONParser do
|
8
|
+
|
9
|
+
before do
|
10
|
+
@listener = Gherkin::SexpRecorder.new
|
11
|
+
@parser = Gherkin::Parser::JSONParser.new(@listener)
|
12
|
+
end
|
13
|
+
|
14
|
+
describe "An empty feature" do
|
15
|
+
it "should parse empty features" do
|
16
|
+
@parser.parse('{}')
|
17
|
+
@listener.to_sexp.should == [
|
18
|
+
[:eof]
|
19
|
+
]
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe "A barely empty feature" do
|
24
|
+
it "should parse a feature with no elements" do
|
25
|
+
@parser.parse('{ "name" : "One", "line" : 3 }')
|
26
|
+
@listener.to_sexp.should == [
|
27
|
+
[:feature, "Feature", "One", 3],
|
28
|
+
[:eof]
|
29
|
+
]
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe "Determining language" do
|
34
|
+
it "should pick up the i18n language from attributes" do
|
35
|
+
@parser.parse('{ "language" : "fr" }')
|
36
|
+
@parser.i18n_language.iso_code.should == "fr"
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should default to English if no language is found" do
|
40
|
+
@parser.parse('{ "name": "A Featuer" }')
|
41
|
+
@parser.i18n_language.iso_code.should == "en"
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe "Missing line numbers" do
|
46
|
+
it "should indicate a line number of 0 if a line attribute doesn't exist" do
|
47
|
+
@parser.parse('{ "name" : "My Sweet Featur" }')
|
48
|
+
@listener.to_sexp.should == [
|
49
|
+
[:feature, "Feature", "My Sweet Featur", 0],
|
50
|
+
[:eof]
|
51
|
+
]
|
52
|
+
end
|
53
|
+
|
54
|
+
it "should use line number from file_colon_line if exists" do
|
55
|
+
@parser.parse('{ "name" : "My Sweet Featur",
|
56
|
+
"file_colon_line": "my_nice_feature.js:12" }')
|
57
|
+
@listener.to_sexp.should == [
|
58
|
+
[:feature, "Feature", "My Sweet Featur", 12],
|
59
|
+
[:eof]
|
60
|
+
]
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
describe "Keywords" do
|
65
|
+
it "should use the keyword from the source when provided" do
|
66
|
+
@parser.parse('{ "name" : "My Sweet Featur", "language": "fr", "keyword": "Feature" }')
|
67
|
+
@listener.to_sexp.should == [
|
68
|
+
[:feature, "Feature", "My Sweet Featur", 0],
|
69
|
+
[:eof]
|
70
|
+
]
|
71
|
+
end
|
72
|
+
|
73
|
+
it "should use a default keyword from the i18n_language if no keyword is provided" do
|
74
|
+
@parser.parse('{ "name" : "My Sweet Featur", "language": "fr" }')
|
75
|
+
@listener.to_sexp.should == [
|
76
|
+
[:feature, "Fonctionnalité", "My Sweet Featur", 0],
|
77
|
+
[:eof]
|
78
|
+
]
|
79
|
+
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
describe "A complex feature with tags, comments, multiple scenarios, and multiple steps and tables" do
|
84
|
+
it "should find things in the right order" do
|
85
|
+
parse_file("complex.js")
|
86
|
+
@listener.to_sexp.should == [
|
87
|
+
[:tag, "@tag1", 0],
|
88
|
+
[:tag, "@tag2", 0],
|
89
|
+
[:feature, "Feature", "Feature Text\nIn order to test multiline forms", 0],
|
90
|
+
[:background, "Background", "", 0],
|
91
|
+
[:step, "Given ", "this is a background step", 0],
|
92
|
+
[:step, "When ", "this is another one", 412],
|
93
|
+
[:tag, "@foo", 0],
|
94
|
+
[:scenario_outline, "Scenario Outline", "An Scenario Outline", 0],
|
95
|
+
[:step, "Given ", "A step with a table", 0],
|
96
|
+
[:row, %w{a row for a step}, 0],
|
97
|
+
[:tag, "@exampletag", 0],
|
98
|
+
[:examples, "Examples", "Sweet Example", 0],
|
99
|
+
[:row, %w{Fill In}, 0],
|
100
|
+
[:row, %w{The Blanks}, 0],
|
101
|
+
[:tag, "@tag3", 0],
|
102
|
+
[:tag, "@tag4", 0],
|
103
|
+
[:scenario, "Scenario", "Reading a Scenario", 0],
|
104
|
+
[:step, "Given ", "there is a step", 0],
|
105
|
+
[:step, "Given ", "not another step", 0],
|
106
|
+
[:tag, "@tag3", 0],
|
107
|
+
[:scenario, "Scenario", "Reading a second scenario\nWith two lines of text", 0],
|
108
|
+
[:step, "Given ", "a third step with a table", 0],
|
109
|
+
[:row, %w{a b}, 0],
|
110
|
+
[:row, %w{c d}, 0],
|
111
|
+
[:row, %w{e f}, 0],
|
112
|
+
[:step, "Given ", "I am still testing things", 0],
|
113
|
+
[:row, %w{g h}, 0],
|
114
|
+
[:row, %w{e r}, 0],
|
115
|
+
[:row, %w{k i}, 0],
|
116
|
+
[:row, ['n', ''], 0],
|
117
|
+
[:step, "Given ", "I am done testing these tables", 0],
|
118
|
+
[:step, "Given ", "I am happy", 0],
|
119
|
+
[:scenario, "Scenario", "Hammerzeit", 0],
|
120
|
+
[:step, "Given ", "All work and no play", 0],
|
121
|
+
[:py_string, "Makes Homer something something\nAnd something else", 0 ],
|
122
|
+
[:step, "Given ", "crazy", 0],
|
123
|
+
[:eof]
|
124
|
+
]
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
require 'gherkin/parser/parser'
|
3
3
|
|
4
4
|
module Gherkin
|
@@ -6,7 +6,7 @@ module Gherkin
|
|
6
6
|
describe Parser do
|
7
7
|
before do
|
8
8
|
@listener = mock('listener')
|
9
|
-
@parser = Parser.new(@listener, true)
|
9
|
+
@parser = Gherkin::Parser::Parser.new(@listener, true)
|
10
10
|
end
|
11
11
|
|
12
12
|
it "should delegate events to the listener" do
|
@@ -16,7 +16,7 @@ module Gherkin
|
|
16
16
|
|
17
17
|
it "should raise helpful error messages by default" do
|
18
18
|
lambda {
|
19
|
-
@parser.scenario("Scenario", "My pet scenario", 12)
|
19
|
+
@parser.scenario("Scenario", "My pet scenario", "", 12)
|
20
20
|
}.should raise_error(/Parse error on line 12\. Found scenario when expecting one of: comment, feature, tag\. \(Current state: root\)\.$/)
|
21
21
|
end
|
22
22
|
|
@@ -27,22 +27,22 @@ module Gherkin
|
|
27
27
|
|
28
28
|
it "should delegate an error message when raise on error is false" do
|
29
29
|
@listener.should_receive(:syntax_error).with(sym(:root), sym(:background), a([:comment, :feature, :tag]), 1)
|
30
|
-
@parser = Parser.new(@listener, false)
|
31
|
-
@parser.background("Background", "Content", 1)
|
30
|
+
@parser = Gherkin::Parser::Parser.new(@listener, false)
|
31
|
+
@parser.background("Background", "Content", "", 1)
|
32
32
|
end
|
33
33
|
|
34
34
|
[true, false].each do |native|
|
35
35
|
it "should be reusable for several feature files (native lexer: #{native})" do
|
36
|
-
listener = mock('listener'
|
37
|
-
parser = Parser.new(listener, true)
|
36
|
+
listener = mock('listener').as_null_object
|
37
|
+
parser = Gherkin::Parser::Parser.new(listener, true)
|
38
38
|
lexer = Gherkin::I18nLexer.new(parser, native)
|
39
39
|
feature = <<-EOF
|
40
40
|
Feature: foo
|
41
41
|
Scenario: bar
|
42
42
|
Given zap
|
43
43
|
EOF
|
44
|
-
lexer.scan(feature)
|
45
|
-
lexer.scan(feature)
|
44
|
+
lexer.scan(feature, "test.feature", 0)
|
45
|
+
lexer.scan(feature, "test.feature", 0)
|
46
46
|
end
|
47
47
|
end
|
48
48
|
end
|