benhamill-gherkin 2.3.5
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitattributes +2 -0
- data/.gitignore +11 -0
- data/.mailmap +2 -0
- data/.rspec +1 -0
- data/.rvmrc +1 -0
- data/Gemfile +7 -0
- data/History.txt +363 -0
- data/LICENSE +20 -0
- data/README.rdoc +149 -0
- data/Rakefile +19 -0
- data/VERSION +1 -0
- data/build_native_gems.sh +8 -0
- data/cucumber.yml +3 -0
- data/features/escaped_pipes.feature +8 -0
- data/features/feature_parser.feature +237 -0
- data/features/json_formatter.feature +377 -0
- data/features/json_parser.feature +318 -0
- data/features/native_lexer.feature +19 -0
- data/features/parser_with_native_lexer.feature +205 -0
- data/features/pretty_formatter.feature +15 -0
- data/features/step_definitions/eyeball_steps.rb +3 -0
- data/features/step_definitions/gherkin_steps.rb +29 -0
- data/features/step_definitions/json_formatter_steps.rb +28 -0
- data/features/step_definitions/json_parser_steps.rb +20 -0
- data/features/step_definitions/pretty_formatter_steps.rb +84 -0
- data/features/steps_parser.feature +46 -0
- data/features/support/env.rb +38 -0
- data/gherkin.gemspec +61 -0
- data/ikvm/.gitignore +3 -0
- data/java/.gitignore +5 -0
- data/java/src/main/java/gherkin/lexer/i18n/.gitignore +1 -0
- data/java/src/main/resources/gherkin/.gitignore +1 -0
- data/js/lib/gherkin/lexer/i18n/ar.js +1094 -0
- data/js/lib/gherkin/lexer/i18n/bg.js +1308 -0
- data/js/lib/gherkin/lexer/i18n/ca.js +1236 -0
- data/js/lib/gherkin/lexer/i18n/cs.js +1090 -0
- data/js/lib/gherkin/lexer/i18n/cy_gb.js +958 -0
- data/js/lib/gherkin/lexer/i18n/da.js +974 -0
- data/js/lib/gherkin/lexer/i18n/de.js +1082 -0
- data/js/lib/gherkin/lexer/i18n/en.js +965 -0
- data/js/lib/gherkin/lexer/i18n/en_au.js +902 -0
- data/js/lib/gherkin/lexer/i18n/en_lol.js +859 -0
- data/js/lib/gherkin/lexer/i18n/en_pirate.js +1136 -0
- data/js/lib/gherkin/lexer/i18n/en_scouse.js +1289 -0
- data/js/lib/gherkin/lexer/i18n/en_tx.js +942 -0
- data/js/lib/gherkin/lexer/i18n/eo.js +916 -0
- data/js/lib/gherkin/lexer/i18n/es.js +1049 -0
- data/js/lib/gherkin/lexer/i18n/et.js +915 -0
- data/js/lib/gherkin/lexer/i18n/fi.js +894 -0
- data/js/lib/gherkin/lexer/i18n/fr.js +1116 -0
- data/js/lib/gherkin/lexer/i18n/he.js +1044 -0
- data/js/lib/gherkin/lexer/i18n/hr.js +994 -0
- data/js/lib/gherkin/lexer/i18n/hu.js +1043 -0
- data/js/lib/gherkin/lexer/i18n/id.js +884 -0
- data/js/lib/gherkin/lexer/i18n/it.js +1007 -0
- data/js/lib/gherkin/lexer/i18n/ja.js +1344 -0
- data/js/lib/gherkin/lexer/i18n/ko.js +1028 -0
- data/js/lib/gherkin/lexer/i18n/lt.js +972 -0
- data/js/lib/gherkin/lexer/i18n/lu.js +1057 -0
- data/js/lib/gherkin/lexer/i18n/lv.js +1092 -0
- data/js/lib/gherkin/lexer/i18n/nl.js +1036 -0
- data/js/lib/gherkin/lexer/i18n/no.js +986 -0
- data/js/lib/gherkin/lexer/i18n/pl.js +1140 -0
- data/js/lib/gherkin/lexer/i18n/pt.js +1000 -0
- data/js/lib/gherkin/lexer/i18n/ro.js +1089 -0
- data/js/lib/gherkin/lexer/i18n/ru.js +1560 -0
- data/js/lib/gherkin/lexer/i18n/sk.js +972 -0
- data/js/lib/gherkin/lexer/i18n/sr_cyrl.js +1728 -0
- data/js/lib/gherkin/lexer/i18n/sr_latn.js +1220 -0
- data/js/lib/gherkin/lexer/i18n/sv.js +997 -0
- data/js/lib/gherkin/lexer/i18n/tr.js +1014 -0
- data/js/lib/gherkin/lexer/i18n/uk.js +1572 -0
- data/js/lib/gherkin/lexer/i18n/uz.js +1302 -0
- data/js/lib/gherkin/lexer/i18n/vi.js +1124 -0
- data/js/lib/gherkin/lexer/i18n/zh_cn.js +902 -0
- data/js/lib/gherkin/lexer/i18n/zh_tw.js +940 -0
- data/lib/.gitignore +4 -0
- data/lib/gherkin.rb +2 -0
- data/lib/gherkin/c_lexer.rb +17 -0
- data/lib/gherkin/formatter/ansi_escapes.rb +95 -0
- data/lib/gherkin/formatter/argument.rb +16 -0
- data/lib/gherkin/formatter/escaping.rb +15 -0
- data/lib/gherkin/formatter/filter_formatter.rb +136 -0
- data/lib/gherkin/formatter/hashable.rb +19 -0
- data/lib/gherkin/formatter/json_formatter.rb +102 -0
- data/lib/gherkin/formatter/line_filter.rb +26 -0
- data/lib/gherkin/formatter/model.rb +236 -0
- data/lib/gherkin/formatter/pretty_formatter.rb +243 -0
- data/lib/gherkin/formatter/regexp_filter.rb +21 -0
- data/lib/gherkin/formatter/step_printer.rb +17 -0
- data/lib/gherkin/formatter/tag_count_formatter.rb +47 -0
- data/lib/gherkin/formatter/tag_filter.rb +19 -0
- data/lib/gherkin/i18n.rb +175 -0
- data/lib/gherkin/i18n.yml +588 -0
- data/lib/gherkin/json_parser.rb +137 -0
- data/lib/gherkin/lexer/i18n_lexer.rb +47 -0
- data/lib/gherkin/listener/event.rb +45 -0
- data/lib/gherkin/listener/formatter_listener.rb +113 -0
- data/lib/gherkin/native.rb +7 -0
- data/lib/gherkin/native/ikvm.rb +55 -0
- data/lib/gherkin/native/java.rb +55 -0
- data/lib/gherkin/native/null.rb +9 -0
- data/lib/gherkin/parser/meta.txt +5 -0
- data/lib/gherkin/parser/parser.rb +164 -0
- data/lib/gherkin/parser/root.txt +11 -0
- data/lib/gherkin/parser/steps.txt +4 -0
- data/lib/gherkin/rb_lexer.rb +8 -0
- data/lib/gherkin/rb_lexer/.gitignore +1 -0
- data/lib/gherkin/rb_lexer/README.rdoc +8 -0
- data/lib/gherkin/rubify.rb +24 -0
- data/lib/gherkin/tag_expression.rb +62 -0
- data/lib/gherkin/version.rb +3 -0
- data/ragel/i18n/.gitignore +1 -0
- data/ragel/lexer.c.rl.erb +439 -0
- data/ragel/lexer.java.rl.erb +208 -0
- data/ragel/lexer.rb.rl.erb +167 -0
- data/ragel/lexer_common.rl.erb +50 -0
- data/spec/gherkin/c_lexer_spec.rb +21 -0
- data/spec/gherkin/fixtures/1.feature +8 -0
- data/spec/gherkin/fixtures/comments_in_table.feature +9 -0
- data/spec/gherkin/fixtures/complex.feature +45 -0
- data/spec/gherkin/fixtures/complex.json +143 -0
- data/spec/gherkin/fixtures/complex_for_filtering.feature +60 -0
- data/spec/gherkin/fixtures/complex_with_tags.feature +61 -0
- data/spec/gherkin/fixtures/dos_line_endings.feature +45 -0
- data/spec/gherkin/fixtures/hantu_pisang.feature +35 -0
- data/spec/gherkin/fixtures/i18n_fr.feature +14 -0
- data/spec/gherkin/fixtures/i18n_no.feature +7 -0
- data/spec/gherkin/fixtures/i18n_zh-CN.feature +9 -0
- data/spec/gherkin/fixtures/scenario_outline_with_tags.feature +13 -0
- data/spec/gherkin/fixtures/scenario_without_steps.feature +5 -0
- data/spec/gherkin/fixtures/simple_with_comments.feature +7 -0
- data/spec/gherkin/fixtures/simple_with_tags.feature +11 -0
- data/spec/gherkin/fixtures/with_bom.feature +3 -0
- data/spec/gherkin/formatter/ansi_escapes_spec.rb +19 -0
- data/spec/gherkin/formatter/filter_formatter_spec.rb +165 -0
- data/spec/gherkin/formatter/model_spec.rb +28 -0
- data/spec/gherkin/formatter/pretty_formatter_spec.rb +158 -0
- data/spec/gherkin/formatter/spaces.feature +9 -0
- data/spec/gherkin/formatter/step_printer_spec.rb +55 -0
- data/spec/gherkin/formatter/tabs.feature +9 -0
- data/spec/gherkin/formatter/tag_count_formatter_spec.rb +30 -0
- data/spec/gherkin/i18n_spec.rb +152 -0
- data/spec/gherkin/java_lexer_spec.rb +20 -0
- data/spec/gherkin/java_libs.rb +20 -0
- data/spec/gherkin/json_parser_spec.rb +113 -0
- data/spec/gherkin/lexer/i18n_lexer_spec.rb +43 -0
- data/spec/gherkin/output_stream_string_io.rb +20 -0
- data/spec/gherkin/parser/parser_spec.rb +16 -0
- data/spec/gherkin/rb_lexer_spec.rb +19 -0
- data/spec/gherkin/sexp_recorder.rb +56 -0
- data/spec/gherkin/shared/lexer_group.rb +593 -0
- data/spec/gherkin/shared/py_string_group.rb +153 -0
- data/spec/gherkin/shared/row_group.rb +125 -0
- data/spec/gherkin/shared/tags_group.rb +54 -0
- data/spec/gherkin/tag_expression_spec.rb +137 -0
- data/spec/spec_helper.rb +69 -0
- data/tasks/bench.rake +184 -0
- data/tasks/bench/feature_builder.rb +49 -0
- data/tasks/bench/generated/.gitignore +1 -0
- data/tasks/bench/null_listener.rb +4 -0
- data/tasks/compile.rake +102 -0
- data/tasks/cucumber.rake +20 -0
- data/tasks/gems.rake +35 -0
- data/tasks/ikvm.rake +79 -0
- data/tasks/ragel_task.rb +70 -0
- data/tasks/rdoc.rake +9 -0
- data/tasks/release.rake +30 -0
- data/tasks/rspec.rake +8 -0
- metadata +609 -0
@@ -0,0 +1,30 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
require 'gherkin/parser/parser'
|
4
|
+
require 'gherkin/formatter/tag_count_formatter'
|
5
|
+
|
6
|
+
module Gherkin
|
7
|
+
module Formatter
|
8
|
+
describe TagCountFormatter do
|
9
|
+
it "should count tags" do
|
10
|
+
tag_counts = {}
|
11
|
+
dummy = Gherkin::SexpRecorder.new
|
12
|
+
formatter = Gherkin::Formatter::TagCountFormatter.new(dummy, tag_counts)
|
13
|
+
parser = Gherkin::Parser::Parser.new(formatter)
|
14
|
+
|
15
|
+
f = File.new(File.dirname(__FILE__) + "/../fixtures/complex_with_tags.feature").read
|
16
|
+
parser.parse(f, 'f.feature', 0)
|
17
|
+
|
18
|
+
tag_counts.should == {
|
19
|
+
"@hamster" => ["f.feature:58"],
|
20
|
+
"@tag1" => ["f.feature:18","f.feature:23","f.feature:39","f.feature:52","f.feature:58"],
|
21
|
+
"@tag2" => ["f.feature:18","f.feature:23","f.feature:39","f.feature:52","f.feature:58"],
|
22
|
+
"@tag3" => ["f.feature:18", "f.feature:23"],
|
23
|
+
"@tag4" => ["f.feature:18"],
|
24
|
+
"@neat" => ["f.feature:52"],
|
25
|
+
"@more" => ["f.feature:52", "f.feature:58"]
|
26
|
+
}
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,152 @@
|
|
1
|
+
#encoding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
module Gherkin
|
5
|
+
module Lexer
|
6
|
+
describe I18n do
|
7
|
+
before do
|
8
|
+
@listener = Gherkin::SexpRecorder.new
|
9
|
+
end
|
10
|
+
|
11
|
+
def scan_file(lexer, file)
|
12
|
+
lexer.scan(File.new(File.dirname(__FILE__) + "/fixtures/" + file).read)
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should recognize keywords in the language of the lexer" do
|
16
|
+
lexer = Gherkin::Lexer::I18nLexer.new(@listener, false)
|
17
|
+
scan_file(lexer, "i18n_no.feature")
|
18
|
+
@listener.to_sexp.should == [
|
19
|
+
[:comment, "#language:no", 1],
|
20
|
+
[:feature, "Egenskap", "i18n support", "", 2],
|
21
|
+
[:scenario, "Scenario", "Parsing many languages", "", 4],
|
22
|
+
[:step, "Gitt ", "Gherkin supports many languages", 5],
|
23
|
+
[:step, "Når ", "Norwegian keywords are parsed", 6],
|
24
|
+
[:step, "Så ", "they should be recognized", 7],
|
25
|
+
[:eof]
|
26
|
+
]
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should parse languages without a space after keywords" do
|
30
|
+
lexer = Gherkin::Lexer::I18nLexer.new(@listener, false)
|
31
|
+
scan_file(lexer, "i18n_zh-CN.feature")
|
32
|
+
@listener.to_sexp.should == [
|
33
|
+
[:comment, "#language:zh-CN", 1],
|
34
|
+
[:feature, "功能", "加法", "", 2],
|
35
|
+
[:scenario, "场景", "两个数相加", "", 4],
|
36
|
+
[:step, "假如", "我已经在计算器里输入6", 5],
|
37
|
+
[:step, "而且", "我已经在计算器里输入7", 6],
|
38
|
+
[:step, "当", "我按相加按钮", 7],
|
39
|
+
[:step, "那么", "我应该在屏幕上看到的结果是13", 8],
|
40
|
+
[:eof]
|
41
|
+
]
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should parse languages with spaces after some keywords but not others" do
|
45
|
+
lexer = Gherkin::Lexer::I18nLexer.new(@listener, false)
|
46
|
+
scan_file(lexer, "i18n_fr.feature")
|
47
|
+
@listener.to_sexp.should == [
|
48
|
+
[:comment, "#language:fr", 1],
|
49
|
+
[:feature, "Fonctionnalité", "Addition", "", 2],
|
50
|
+
[:scenario_outline, "Plan du scénario", "Addition de produits dérivés", "", 3],
|
51
|
+
[:step, "Soit ", "une calculatrice", 4],
|
52
|
+
[:step, "Etant donné ", "qu'on tape <a>", 5],
|
53
|
+
[:step, "Et ", "qu'on tape <b>", 6],
|
54
|
+
[:step, "Lorsqu'", "on tape additionner", 7],
|
55
|
+
[:step, "Alors ", "le résultat doit être <somme>", 8],
|
56
|
+
[:examples, "Exemples", "", "", 10],
|
57
|
+
[:row, %w{a b somme}, 11],
|
58
|
+
[:row, %w{2 2 4}, 12],
|
59
|
+
[:row, %w{2 3 5}, 13],
|
60
|
+
[:eof]
|
61
|
+
]
|
62
|
+
end
|
63
|
+
|
64
|
+
describe 'keywords' do
|
65
|
+
it "should have code keywords without space, comma, exclamation or apostrophe" do
|
66
|
+
['Avast', 'Akkor', 'Etantdonné', 'Lorsque', '假設'].each do |code_keyword|
|
67
|
+
Gherkin::I18n.code_keywords.should include(code_keyword)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
it "should reject the bullet stars" do
|
72
|
+
Gherkin::I18n.code_keywords.should_not include('*')
|
73
|
+
end
|
74
|
+
|
75
|
+
it "should report keyword regexp" do
|
76
|
+
Gherkin::I18n.keyword_regexp(:step).should =~ /\|Quando \|Quand \|Quan \|Pryd \|Pokud \|/
|
77
|
+
end
|
78
|
+
|
79
|
+
unless defined?(JRUBY_VERSION)
|
80
|
+
it "should print available languages" do
|
81
|
+
("\n" + Gherkin::I18n.language_table).should == %{
|
82
|
+
| ar | Arabic | العربية |
|
83
|
+
| bg | Bulgarian | български |
|
84
|
+
| ca | Catalan | català |
|
85
|
+
| cs | Czech | Česky |
|
86
|
+
| cy-GB | Welsh | Cymraeg |
|
87
|
+
| da | Danish | dansk |
|
88
|
+
| de | German | Deutsch |
|
89
|
+
| en | English | English |
|
90
|
+
| en-Scouse | Scouse | Scouse |
|
91
|
+
| en-au | Australian | Australian |
|
92
|
+
| en-lol | LOLCAT | LOLCAT |
|
93
|
+
| en-pirate | Pirate | Pirate |
|
94
|
+
| en-tx | Texan | Texan |
|
95
|
+
| eo | Esperanto | Esperanto |
|
96
|
+
| es | Spanish | español |
|
97
|
+
| et | Estonian | eesti keel |
|
98
|
+
| fi | Finnish | suomi |
|
99
|
+
| fr | French | français |
|
100
|
+
| he | Hebrew | עברית |
|
101
|
+
| hr | Croatian | hrvatski |
|
102
|
+
| hu | Hungarian | magyar |
|
103
|
+
| id | Indonesian | Bahasa Indonesia |
|
104
|
+
| it | Italian | italiano |
|
105
|
+
| ja | Japanese | 日本語 |
|
106
|
+
| ko | Korean | 한국어 |
|
107
|
+
| lt | Lithuanian | lietuvių kalba |
|
108
|
+
| lu | Luxemburgish | Lëtzebuergesch |
|
109
|
+
| lv | Latvian | latviešu |
|
110
|
+
| nl | Dutch | Nederlands |
|
111
|
+
| no | Norwegian | norsk |
|
112
|
+
| pl | Polish | polski |
|
113
|
+
| pt | Portuguese | português |
|
114
|
+
| ro | Romanian | română |
|
115
|
+
| ru | Russian | русский |
|
116
|
+
| sk | Slovak | Slovensky |
|
117
|
+
| sr-Cyrl | Serbian | Српски |
|
118
|
+
| sr-Latn | Serbian (Latin) | Srpski (Latinica) |
|
119
|
+
| sv | Swedish | Svenska |
|
120
|
+
| tr | Turkish | Türkçe |
|
121
|
+
| uk | Ukrainian | Українська |
|
122
|
+
| uz | Uzbek | Узбекча |
|
123
|
+
| vi | Vietnamese | Tiếng Việt |
|
124
|
+
| zh-CN | Chinese simplified | 简体中文 |
|
125
|
+
| zh-TW | Chinese traditional | 繁體中文 |
|
126
|
+
}
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
it "should print keywords for a given language" do
|
131
|
+
("\n" + Gherkin::I18n.get('fr').keyword_table).should == %{
|
132
|
+
| feature | "Fonctionnalité" |
|
133
|
+
| background | "Contexte" |
|
134
|
+
| scenario | "Scénario" |
|
135
|
+
| scenario_outline | "Plan du scénario", "Plan du Scénario" |
|
136
|
+
| examples | "Exemples" |
|
137
|
+
| given | "* ", "Soit ", "Etant donné " |
|
138
|
+
| when | "* ", "Quand ", "Lorsque ", "Lorsqu'" |
|
139
|
+
| then | "* ", "Alors " |
|
140
|
+
| and | "* ", "Et " |
|
141
|
+
| but | "* ", "Mais " |
|
142
|
+
| given (code) | "Soit", "Etantdonné" |
|
143
|
+
| when (code) | "Quand", "Lorsque", "Lorsqu" |
|
144
|
+
| then (code) | "Alors" |
|
145
|
+
| and (code) | "Et" |
|
146
|
+
| but (code) | "Mais" |
|
147
|
+
}
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end
|
151
|
+
end
|
152
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
#encoding: utf-8
|
2
|
+
if defined?(JRUBY_VERSION)
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
module Gherkin
|
6
|
+
module JavaLexer
|
7
|
+
describe "Java Lexer" do
|
8
|
+
before do
|
9
|
+
@listener = Gherkin::SexpRecorder.new
|
10
|
+
@lexer = Java::GherkinLexer::I18nLexer.new(@listener)
|
11
|
+
end
|
12
|
+
|
13
|
+
it_should_behave_like "a Gherkin lexer"
|
14
|
+
it_should_behave_like "a Gherkin lexer lexing tags"
|
15
|
+
it_should_behave_like "a Gherkin lexer lexing py_strings"
|
16
|
+
it_should_behave_like "a Gherkin lexer lexing rows"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
JAVA_LIBS = {}
|
2
|
+
|
3
|
+
unless RUBY_VERSION == '1.8.6'
|
4
|
+
# When we're building native windows gems with 1.8.6 this block of code fails.
|
5
|
+
# We'll just disable running it - it's not needed at that stage of the build.
|
6
|
+
|
7
|
+
require 'rexml/document'
|
8
|
+
pom = REXML::Document.new(IO.read(File.dirname(__FILE__) + '/../../java/pom.xml'))
|
9
|
+
pom_version = REXML::XPath.first(pom, '//xmlns:project/xmlns:version/text()').to_s
|
10
|
+
REXML::XPath.each(pom, '//xmlns:project/xmlns:dependencies/xmlns:dependency').each do |dep|
|
11
|
+
groupId = dep.get_elements('groupId')[0].text()
|
12
|
+
artifactId = dep.get_elements('artifactId')[0].text()
|
13
|
+
version = dep.get_elements('version')[0].text()
|
14
|
+
scope = dep.get_elements('scope')[0].text() rescue nil
|
15
|
+
|
16
|
+
jar = "~/.m2/repository/#{groupId.gsub(/\./, '/')}/#{artifactId}/#{version}/#{artifactId}-#{version}.jar"
|
17
|
+
JAVA_LIBS["#{groupId}-#{artifactId}"] = jar if scope != 'test'
|
18
|
+
require jar if defined?(JRUBY_VERSION)
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,113 @@
|
|
1
|
+
#encoding: utf-8
|
2
|
+
require 'ap'
|
3
|
+
require 'spec_helper'
|
4
|
+
require 'gherkin/json_parser'
|
5
|
+
require 'gherkin/formatter/json_formatter'
|
6
|
+
|
7
|
+
module Gherkin
|
8
|
+
describe JSONParser do
|
9
|
+
|
10
|
+
def check_json(json)
|
11
|
+
io = StringIO.new
|
12
|
+
f = Formatter::JSONFormatter.new(io)
|
13
|
+
p = JSONParser.new(f)
|
14
|
+
p.parse(json, 'unknown.json', 0)
|
15
|
+
expected = JSON.parse(json)
|
16
|
+
actual = JSON.parse(io.string)
|
17
|
+
actual.should == expected
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should parse a barely empty feature" do
|
21
|
+
check_json(%{{
|
22
|
+
"keyword": "Feature",
|
23
|
+
"name": "One",
|
24
|
+
"description": "",
|
25
|
+
"line" : 3
|
26
|
+
}})
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should parse feature with tags and one scenario" do
|
30
|
+
check_json(%{{
|
31
|
+
"tags": [
|
32
|
+
{
|
33
|
+
"name": "@foo",
|
34
|
+
"line": 22
|
35
|
+
}
|
36
|
+
],
|
37
|
+
"keyword": "Feature",
|
38
|
+
"name": "One",
|
39
|
+
"description": "",
|
40
|
+
"line": 3,
|
41
|
+
"elements": [
|
42
|
+
{
|
43
|
+
"type": "scenario",
|
44
|
+
"steps": [
|
45
|
+
{
|
46
|
+
"name": "Hello",
|
47
|
+
"multiline_arg": {
|
48
|
+
"type": "table",
|
49
|
+
"value": [
|
50
|
+
{
|
51
|
+
"cells": ["foo", "bar"]
|
52
|
+
}
|
53
|
+
]
|
54
|
+
}
|
55
|
+
}
|
56
|
+
]
|
57
|
+
}
|
58
|
+
]
|
59
|
+
}})
|
60
|
+
end
|
61
|
+
|
62
|
+
it "should parse feature with match, result and embedding" do
|
63
|
+
check_json(%{{
|
64
|
+
"tags": [
|
65
|
+
{
|
66
|
+
"name": "@foo",
|
67
|
+
"line": 22
|
68
|
+
}
|
69
|
+
],
|
70
|
+
"keyword": "Feature",
|
71
|
+
"name": "One",
|
72
|
+
"description": "",
|
73
|
+
"line": 3,
|
74
|
+
"elements": [
|
75
|
+
{
|
76
|
+
"type": "scenario",
|
77
|
+
"steps": [
|
78
|
+
{
|
79
|
+
"keyword": "Given ",
|
80
|
+
"name": "a passing step",
|
81
|
+
"line": 6,
|
82
|
+
"match": {
|
83
|
+
"arguments": [
|
84
|
+
{
|
85
|
+
"offset": 22,
|
86
|
+
"val": "cukes"
|
87
|
+
}
|
88
|
+
],
|
89
|
+
"location": "features/step_definitions/steps.rb:1"
|
90
|
+
},
|
91
|
+
"result": {
|
92
|
+
"status": "failed",
|
93
|
+
"error_message": "You suck",
|
94
|
+
"duration": -1
|
95
|
+
},
|
96
|
+
"embeddings": [
|
97
|
+
{
|
98
|
+
"mime_type": "text/plain",
|
99
|
+
"data": "Tm8sIEknbSBub3QgaW50ZXJlc3RlZCBpbiBkZXZlbG9waW5nIGEgcG93ZXJmdWwgYnJhaW4uIEFsbCBJJ20gYWZ0ZXIgaXMganVzdCBhIG1lZGlvY3JlIGJyYWluLCBzb21ldGhpbmcgbGlrZSB0aGUgUHJlc2lkZW50IG9mIHRoZSBBbWVyaWNhbiBUZWxlcGhvbmUgYW5kIFRlbGVncmFwaCBDb21wYW55Lg=="
|
100
|
+
}
|
101
|
+
]
|
102
|
+
}
|
103
|
+
]
|
104
|
+
}
|
105
|
+
]
|
106
|
+
}})
|
107
|
+
end
|
108
|
+
|
109
|
+
it "shoud parse a complex feature" do
|
110
|
+
check_json(fixture("complex.json"))
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
#encoding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
module Gherkin
|
5
|
+
module Lexer
|
6
|
+
describe I18nLexer do
|
7
|
+
before do
|
8
|
+
@lexer = Gherkin::Lexer::I18nLexer.new(Gherkin::SexpRecorder.new, false)
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should store the i18n language of the last scanned feature" do
|
12
|
+
@lexer.scan("# language: fr\n")
|
13
|
+
@lexer.i18n_language.iso_code.should == "fr"
|
14
|
+
@lexer.scan("# language: no\n")
|
15
|
+
@lexer.i18n_language.iso_code.should == "no"
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should detect language when there are spaces and CRLF" do
|
19
|
+
@lexer.scan("# language: da \r\n")
|
20
|
+
@lexer.i18n_language.iso_code.should == "da"
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should detect language when the language comment is not the first line" do
|
24
|
+
@lexer.scan("# hello\n# language: no\n")
|
25
|
+
@lexer.i18n_language.iso_code.should == "no"
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should detect language when the language is on the third line, and there are empty lines above" do
|
29
|
+
@lexer.scan("# hello\n\n# language: no\n")
|
30
|
+
@lexer.i18n_language.iso_code.should == "no"
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should use English i18n by default" do
|
34
|
+
@lexer.scan("Feature: foo\n")
|
35
|
+
@lexer.i18n_language.iso_code.should == "en"
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should === its ruby class, even when the impl is Java" do
|
39
|
+
Gherkin::Lexer::I18nLexer.should === Gherkin::Lexer::I18nLexer.new(Gherkin::SexpRecorder.new, true)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
if defined?(JRUBY_VERSION)
|
2
|
+
class WriterStringIO < Java.java.io.StringWriter
|
3
|
+
def write(what)
|
4
|
+
super(Java.java.lang.String.new(what.to_s))
|
5
|
+
end
|
6
|
+
|
7
|
+
def string
|
8
|
+
toString()
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
require 'stringio'
|
13
|
+
class StringIO
|
14
|
+
class << self
|
15
|
+
def new
|
16
|
+
WriterStringIO.new
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Gherkin
|
4
|
+
module Parser
|
5
|
+
describe Parser do
|
6
|
+
unless defined?(JRUBY_VERSION)
|
7
|
+
it "should raise when feature doesn't parse" do
|
8
|
+
p = Parser.new(mock('formatter').as_null_object)
|
9
|
+
lambda do
|
10
|
+
p.parse("Feature: f\nFeature: f", __FILE__, __LINE__-1)
|
11
|
+
end.should raise_error(/Parse error at/)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
#encoding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
require 'gherkin/rb_lexer/en'
|
4
|
+
|
5
|
+
module Gherkin
|
6
|
+
module Lexer
|
7
|
+
describe "Ruby Lexer" do
|
8
|
+
before do
|
9
|
+
@listener = Gherkin::SexpRecorder.new
|
10
|
+
@lexer = Gherkin::RbLexer::En.new(@listener)
|
11
|
+
end
|
12
|
+
|
13
|
+
it_should_behave_like "a Gherkin lexer"
|
14
|
+
it_should_behave_like "a Gherkin lexer lexing tags"
|
15
|
+
it_should_behave_like "a Gherkin lexer lexing py_strings"
|
16
|
+
it_should_behave_like "a Gherkin lexer lexing rows"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|