gherkin 2.12.2 → 3.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -15
- data/CONTRIBUTING.md +23 -0
- data/Gemfile +0 -3
- data/LICENSE +18 -17
- data/Makefile +65 -0
- data/README.md +9 -268
- data/Rakefile +17 -19
- data/bin/gherkin-generate-ast +21 -0
- data/bin/gherkin-generate-pickles +25 -0
- data/bin/gherkin-generate-tokens +12 -0
- data/gherkin-ruby.razor +218 -0
- data/gherkin.gemspec +22 -76
- data/lib/gherkin/ast_builder.rb +243 -0
- data/lib/gherkin/ast_node.rb +30 -0
- data/lib/gherkin/dialect.rb +58 -0
- data/lib/gherkin/errors.rb +45 -0
- data/lib/gherkin/gherkin-languages.json +2968 -0
- data/lib/gherkin/gherkin_line.rb +95 -0
- data/lib/gherkin/parser.rb +1910 -0
- data/lib/gherkin/pickles/compiler.rb +164 -0
- data/lib/gherkin/token.rb +18 -0
- data/lib/gherkin/token_formatter_builder.rb +39 -0
- data/lib/gherkin/token_matcher.rb +169 -0
- data/lib/gherkin/token_scanner.rb +40 -0
- data/spec/capture_warnings.rb +68 -0
- data/spec/coverage.rb +10 -0
- data/spec/gherkin/parser_spec.rb +146 -0
- metadata +60 -567
- data/.gitattributes +0 -2
- data/.mailmap +0 -2
- data/.rbenv-gemsets +0 -1
- data/.rspec +0 -1
- data/.ruby-gemset +0 -1
- data/.ruby-version +0 -1
- data/.yardopts +0 -5
- data/History.md +0 -881
- data/build_native_gems.sh +0 -7
- data/cucumber.yml +0 -5
- data/examples/parse_and_output_json.rb +0 -19
- data/ext/gherkin_lexer_ar/extconf.rb +0 -6
- data/ext/gherkin_lexer_ar/gherkin_lexer_ar.c +0 -1432
- data/ext/gherkin_lexer_bg/extconf.rb +0 -6
- data/ext/gherkin_lexer_bg/gherkin_lexer_bg.c +0 -1655
- data/ext/gherkin_lexer_bm/extconf.rb +0 -6
- data/ext/gherkin_lexer_bm/gherkin_lexer_bm.c +0 -1516
- data/ext/gherkin_lexer_ca/extconf.rb +0 -6
- data/ext/gherkin_lexer_ca/gherkin_lexer_ca.c +0 -1581
- data/ext/gherkin_lexer_cs/extconf.rb +0 -6
- data/ext/gherkin_lexer_cs/gherkin_lexer_cs.c +0 -1515
- data/ext/gherkin_lexer_cy_gb/extconf.rb +0 -6
- data/ext/gherkin_lexer_cy_gb/gherkin_lexer_cy_gb.c +0 -1282
- data/ext/gherkin_lexer_da/extconf.rb +0 -6
- data/ext/gherkin_lexer_da/gherkin_lexer_da.c +0 -1298
- data/ext/gherkin_lexer_de/extconf.rb +0 -6
- data/ext/gherkin_lexer_de/gherkin_lexer_de.c +0 -1425
- data/ext/gherkin_lexer_el/extconf.rb +0 -6
- data/ext/gherkin_lexer_el/gherkin_lexer_el.c +0 -1919
- data/ext/gherkin_lexer_en/extconf.rb +0 -6
- data/ext/gherkin_lexer_en/gherkin_lexer_en.c +0 -1418
- data/ext/gherkin_lexer_en_au/extconf.rb +0 -6
- data/ext/gherkin_lexer_en_au/gherkin_lexer_en_au.c +0 -1765
- data/ext/gherkin_lexer_en_lol/extconf.rb +0 -6
- data/ext/gherkin_lexer_en_lol/gherkin_lexer_en_lol.c +0 -1177
- data/ext/gherkin_lexer_en_old/extconf.rb +0 -6
- data/ext/gherkin_lexer_en_old/gherkin_lexer_en_old.c +0 -1309
- data/ext/gherkin_lexer_en_pirate/extconf.rb +0 -6
- data/ext/gherkin_lexer_en_pirate/gherkin_lexer_en_pirate.c +0 -1471
- data/ext/gherkin_lexer_en_scouse/extconf.rb +0 -6
- data/ext/gherkin_lexer_en_scouse/gherkin_lexer_en_scouse.c +0 -1634
- data/ext/gherkin_lexer_en_tx/extconf.rb +0 -6
- data/ext/gherkin_lexer_en_tx/gherkin_lexer_en_tx.c +0 -1265
- data/ext/gherkin_lexer_eo/extconf.rb +0 -6
- data/ext/gherkin_lexer_eo/gherkin_lexer_eo.c +0 -1241
- data/ext/gherkin_lexer_es/extconf.rb +0 -6
- data/ext/gherkin_lexer_es/gherkin_lexer_es.c +0 -1399
- data/ext/gherkin_lexer_et/extconf.rb +0 -6
- data/ext/gherkin_lexer_et/gherkin_lexer_et.c +0 -1236
- data/ext/gherkin_lexer_fa/extconf.rb +0 -6
- data/ext/gherkin_lexer_fa/gherkin_lexer_fa.c +0 -1475
- data/ext/gherkin_lexer_fi/extconf.rb +0 -6
- data/ext/gherkin_lexer_fi/gherkin_lexer_fi.c +0 -1215
- data/ext/gherkin_lexer_fr/extconf.rb +0 -6
- data/ext/gherkin_lexer_fr/gherkin_lexer_fr.c +0 -1493
- data/ext/gherkin_lexer_gl/extconf.rb +0 -6
- data/ext/gherkin_lexer_gl/gherkin_lexer_gl.c +0 -1374
- data/ext/gherkin_lexer_he/extconf.rb +0 -6
- data/ext/gherkin_lexer_he/gherkin_lexer_he.c +0 -1374
- data/ext/gherkin_lexer_hi/extconf.rb +0 -6
- data/ext/gherkin_lexer_hi/gherkin_lexer_hi.c +0 -1848
- data/ext/gherkin_lexer_hr/extconf.rb +0 -6
- data/ext/gherkin_lexer_hr/gherkin_lexer_hr.c +0 -1323
- data/ext/gherkin_lexer_hu/extconf.rb +0 -6
- data/ext/gherkin_lexer_hu/gherkin_lexer_hu.c +0 -1376
- data/ext/gherkin_lexer_id/extconf.rb +0 -6
- data/ext/gherkin_lexer_id/gherkin_lexer_id.c +0 -1208
- data/ext/gherkin_lexer_is/extconf.rb +0 -6
- data/ext/gherkin_lexer_is/gherkin_lexer_is.c +0 -1376
- data/ext/gherkin_lexer_it/extconf.rb +0 -6
- data/ext/gherkin_lexer_it/gherkin_lexer_it.c +0 -1340
- data/ext/gherkin_lexer_ja/extconf.rb +0 -6
- data/ext/gherkin_lexer_ja/gherkin_lexer_ja.c +0 -1699
- data/ext/gherkin_lexer_kn/extconf.rb +0 -6
- data/ext/gherkin_lexer_kn/gherkin_lexer_kn.c +0 -1965
- data/ext/gherkin_lexer_ko/extconf.rb +0 -6
- data/ext/gherkin_lexer_ko/gherkin_lexer_ko.c +0 -1360
- data/ext/gherkin_lexer_lt/extconf.rb +0 -6
- data/ext/gherkin_lexer_lt/gherkin_lexer_lt.c +0 -1296
- data/ext/gherkin_lexer_lu/extconf.rb +0 -6
- data/ext/gherkin_lexer_lu/gherkin_lexer_lu.c +0 -1389
- data/ext/gherkin_lexer_lv/extconf.rb +0 -6
- data/ext/gherkin_lexer_lv/gherkin_lexer_lv.c +0 -1425
- data/ext/gherkin_lexer_nl/extconf.rb +0 -6
- data/ext/gherkin_lexer_nl/gherkin_lexer_nl.c +0 -1368
- data/ext/gherkin_lexer_no/extconf.rb +0 -6
- data/ext/gherkin_lexer_no/gherkin_lexer_no.c +0 -1311
- data/ext/gherkin_lexer_pa/extconf.rb +0 -6
- data/ext/gherkin_lexer_pa/gherkin_lexer_pa.c +0 -2160
- data/ext/gherkin_lexer_pl/extconf.rb +0 -6
- data/ext/gherkin_lexer_pl/gherkin_lexer_pl.c +0 -1738
- data/ext/gherkin_lexer_pt/extconf.rb +0 -6
- data/ext/gherkin_lexer_pt/gherkin_lexer_pt.c +0 -1711
- data/ext/gherkin_lexer_ro/extconf.rb +0 -6
- data/ext/gherkin_lexer_ro/gherkin_lexer_ro.c +0 -1427
- data/ext/gherkin_lexer_ru/extconf.rb +0 -6
- data/ext/gherkin_lexer_ru/gherkin_lexer_ru.c +0 -2071
- data/ext/gherkin_lexer_sk/extconf.rb +0 -6
- data/ext/gherkin_lexer_sk/gherkin_lexer_sk.c +0 -1739
- data/ext/gherkin_lexer_sr_cyrl/extconf.rb +0 -6
- data/ext/gherkin_lexer_sr_cyrl/gherkin_lexer_sr_cyrl.c +0 -2112
- data/ext/gherkin_lexer_sr_latn/extconf.rb +0 -6
- data/ext/gherkin_lexer_sr_latn/gherkin_lexer_sr_latn.c +0 -1567
- data/ext/gherkin_lexer_sv/extconf.rb +0 -6
- data/ext/gherkin_lexer_sv/gherkin_lexer_sv.c +0 -1324
- data/ext/gherkin_lexer_th/extconf.rb +0 -6
- data/ext/gherkin_lexer_th/gherkin_lexer_th.c +0 -2840
- data/ext/gherkin_lexer_tl/extconf.rb +0 -6
- data/ext/gherkin_lexer_tl/gherkin_lexer_tl.c +0 -2021
- data/ext/gherkin_lexer_tr/extconf.rb +0 -6
- data/ext/gherkin_lexer_tr/gherkin_lexer_tr.c +0 -1347
- data/ext/gherkin_lexer_tt/extconf.rb +0 -6
- data/ext/gherkin_lexer_tt/gherkin_lexer_tt.c +0 -1936
- data/ext/gherkin_lexer_uk/extconf.rb +0 -6
- data/ext/gherkin_lexer_uk/gherkin_lexer_uk.c +0 -1941
- data/ext/gherkin_lexer_uz/extconf.rb +0 -6
- data/ext/gherkin_lexer_uz/gherkin_lexer_uz.c +0 -1651
- data/ext/gherkin_lexer_vi/extconf.rb +0 -6
- data/ext/gherkin_lexer_vi/gherkin_lexer_vi.c +0 -1458
- data/ext/gherkin_lexer_zh_cn/extconf.rb +0 -6
- data/ext/gherkin_lexer_zh_cn/gherkin_lexer_zh_cn.c +0 -1314
- data/ext/gherkin_lexer_zh_tw/extconf.rb +0 -6
- data/ext/gherkin_lexer_zh_tw/gherkin_lexer_zh_tw.c +0 -1307
- data/features/.cucumber/stepdefs.json +0 -244
- data/features/escaped_pipes.feature +0 -8
- data/features/feature_parser.feature +0 -237
- data/features/json_formatter.feature +0 -498
- data/features/json_parser.feature +0 -331
- data/features/native_lexer.feature +0 -19
- data/features/parser_with_native_lexer.feature +0 -205
- data/features/pretty_formatter.feature +0 -17
- data/features/step_definitions/eyeball_steps.rb +0 -3
- data/features/step_definitions/gherkin_steps.rb +0 -29
- data/features/step_definitions/json_formatter_steps.rb +0 -30
- data/features/step_definitions/json_parser_steps.rb +0 -21
- data/features/step_definitions/pretty_formatter_steps.rb +0 -85
- data/features/steps_parser.feature +0 -46
- data/features/support/env.rb +0 -41
- data/install_mingw_os_x.sh +0 -5
- data/js/.npmignore +0 -1
- data/js/lib/gherkin/lexer/.npmignore +0 -0
- data/lib/gherkin.rb +0 -2
- data/lib/gherkin/README.md +0 -7
- data/lib/gherkin/c_lexer.rb +0 -17
- data/lib/gherkin/formatter/ansi_escapes.rb +0 -97
- data/lib/gherkin/formatter/argument.rb +0 -16
- data/lib/gherkin/formatter/escaping.rb +0 -15
- data/lib/gherkin/formatter/filter_formatter.rb +0 -150
- data/lib/gherkin/formatter/hashable.rb +0 -25
- data/lib/gherkin/formatter/json_formatter.rb +0 -133
- data/lib/gherkin/formatter/line_filter.rb +0 -26
- data/lib/gherkin/formatter/model.rb +0 -281
- data/lib/gherkin/formatter/pretty_formatter.rb +0 -245
- data/lib/gherkin/formatter/regexp_filter.rb +0 -21
- data/lib/gherkin/formatter/step_printer.rb +0 -21
- data/lib/gherkin/formatter/tag_count_formatter.rb +0 -47
- data/lib/gherkin/formatter/tag_filter.rb +0 -19
- data/lib/gherkin/i18n.json +0 -786
- data/lib/gherkin/i18n.rb +0 -176
- data/lib/gherkin/json_parser.rb +0 -177
- data/lib/gherkin/lexer/ar.rb +0 -1170
- data/lib/gherkin/lexer/bg.rb +0 -1382
- data/lib/gherkin/lexer/bm.rb +0 -1250
- data/lib/gherkin/lexer/ca.rb +0 -1310
- data/lib/gherkin/lexer/cs.rb +0 -1246
- data/lib/gherkin/lexer/cy_gb.rb +0 -1032
- data/lib/gherkin/lexer/da.rb +0 -1048
- data/lib/gherkin/lexer/de.rb +0 -1166
- data/lib/gherkin/lexer/el.rb +0 -1628
- data/lib/gherkin/lexer/en.rb +0 -1156
- data/lib/gherkin/lexer/en_au.rb +0 -1486
- data/lib/gherkin/lexer/en_lol.rb +0 -934
- data/lib/gherkin/lexer/en_old.rb +0 -1037
- data/lib/gherkin/lexer/en_pirate.rb +0 -1210
- data/lib/gherkin/lexer/en_scouse.rb +0 -1362
- data/lib/gherkin/lexer/en_tx.rb +0 -1016
- data/lib/gherkin/lexer/encoding.rb +0 -41
- data/lib/gherkin/lexer/eo.rb +0 -995
- data/lib/gherkin/lexer/es.rb +0 -1140
- data/lib/gherkin/lexer/et.rb +0 -990
- data/lib/gherkin/lexer/fa.rb +0 -1214
- data/lib/gherkin/lexer/fi.rb +0 -969
- data/lib/gherkin/lexer/fr.rb +0 -1228
- data/lib/gherkin/lexer/gl.rb +0 -1117
- data/lib/gherkin/lexer/he.rb +0 -1118
- data/lib/gherkin/lexer/hi.rb +0 -1559
- data/lib/gherkin/lexer/hr.rb +0 -1066
- data/lib/gherkin/lexer/hu.rb +0 -1118
- data/lib/gherkin/lexer/i18n_lexer.rb +0 -48
- data/lib/gherkin/lexer/id.rb +0 -963
- data/lib/gherkin/lexer/is.rb +0 -1120
- data/lib/gherkin/lexer/it.rb +0 -1086
- data/lib/gherkin/lexer/ja.rb +0 -1418
- data/lib/gherkin/lexer/kn.rb +0 -1672
- data/lib/gherkin/lexer/ko.rb +0 -1102
- data/lib/gherkin/lexer/lt.rb +0 -1045
- data/lib/gherkin/lexer/lu.rb +0 -1132
- data/lib/gherkin/lexer/lv.rb +0 -1166
- data/lib/gherkin/lexer/nl.rb +0 -1115
- data/lib/gherkin/lexer/no.rb +0 -1060
- data/lib/gherkin/lexer/pa.rb +0 -1852
- data/lib/gherkin/lexer/pl.rb +0 -1457
- data/lib/gherkin/lexer/pt.rb +0 -1430
- data/lib/gherkin/lexer/ro.rb +0 -1164
- data/lib/gherkin/lexer/ru.rb +0 -1766
- data/lib/gherkin/lexer/sk.rb +0 -1452
- data/lib/gherkin/lexer/sr_cyrl.rb +0 -1803
- data/lib/gherkin/lexer/sr_latn.rb +0 -1294
- data/lib/gherkin/lexer/sv.rb +0 -1070
- data/lib/gherkin/lexer/th.rb +0 -2492
- data/lib/gherkin/lexer/tl.rb +0 -1726
- data/lib/gherkin/lexer/tr.rb +0 -1092
- data/lib/gherkin/lexer/tt.rb +0 -1643
- data/lib/gherkin/lexer/uk.rb +0 -1646
- data/lib/gherkin/lexer/uz.rb +0 -1376
- data/lib/gherkin/lexer/vi.rb +0 -1198
- data/lib/gherkin/lexer/zh_cn.rb +0 -1058
- data/lib/gherkin/lexer/zh_tw.rb +0 -1052
- data/lib/gherkin/listener/event.rb +0 -45
- data/lib/gherkin/listener/formatter_listener.rb +0 -150
- data/lib/gherkin/native.rb +0 -7
- data/lib/gherkin/native/java.rb +0 -72
- data/lib/gherkin/native/null.rb +0 -5
- data/lib/gherkin/native/therubyracer.rb +0 -41
- data/lib/gherkin/parser/meta.txt +0 -5
- data/lib/gherkin/parser/parser.rb +0 -166
- data/lib/gherkin/parser/root.txt +0 -11
- data/lib/gherkin/parser/steps.txt +0 -4
- data/lib/gherkin/platform.rb +0 -13
- data/lib/gherkin/rubify.rb +0 -31
- data/lib/gherkin/tag_expression.rb +0 -63
- data/ragel/lexer.c.rl.erb +0 -454
- data/ragel/lexer.java.rl.erb +0 -219
- data/ragel/lexer.js.rl.erb +0 -322
- data/ragel/lexer.rb.rl.erb +0 -179
- data/ragel/lexer_common.rl.erb +0 -50
- data/spec/gherkin/c_lexer_spec.rb +0 -22
- data/spec/gherkin/fixtures/1.feature +0 -8
- data/spec/gherkin/fixtures/comments_in_table.feature +0 -9
- data/spec/gherkin/fixtures/complex.feature +0 -45
- data/spec/gherkin/fixtures/complex.json +0 -139
- data/spec/gherkin/fixtures/complex_for_filtering.feature +0 -60
- data/spec/gherkin/fixtures/complex_with_tags.feature +0 -61
- data/spec/gherkin/fixtures/dos_line_endings.feature +0 -45
- data/spec/gherkin/fixtures/examples_with_only_header.feature +0 -14
- data/spec/gherkin/fixtures/hantu_pisang.feature +0 -35
- data/spec/gherkin/fixtures/i18n_fr.feature +0 -14
- data/spec/gherkin/fixtures/i18n_fr2.feature +0 -8
- data/spec/gherkin/fixtures/i18n_no.feature +0 -7
- data/spec/gherkin/fixtures/i18n_pt1.feature +0 -44
- data/spec/gherkin/fixtures/i18n_pt2.feature +0 -4
- data/spec/gherkin/fixtures/i18n_pt3.feature +0 -4
- data/spec/gherkin/fixtures/i18n_pt4.feature +0 -4
- data/spec/gherkin/fixtures/i18n_zh-CN.feature +0 -9
- data/spec/gherkin/fixtures/iso-8859-1.feature +0 -6
- data/spec/gherkin/fixtures/issue_145.feature +0 -22
- data/spec/gherkin/fixtures/scenario_outline_with_tags.feature +0 -13
- data/spec/gherkin/fixtures/scenario_without_steps.feature +0 -5
- data/spec/gherkin/fixtures/simple_with_comments.feature +0 -7
- data/spec/gherkin/fixtures/simple_with_tags.feature +0 -11
- data/spec/gherkin/fixtures/with_bom.feature +0 -3
- data/spec/gherkin/fixtures/with_bom_and_language_spec.feature +0 -4
- data/spec/gherkin/formatter/ansi_escapes_spec.rb +0 -32
- data/spec/gherkin/formatter/filter_formatter_spec.rb +0 -204
- data/spec/gherkin/formatter/json_formatter_spec.rb +0 -179
- data/spec/gherkin/formatter/model_spec.rb +0 -28
- data/spec/gherkin/formatter/pretty_formatter_spec.rb +0 -184
- data/spec/gherkin/formatter/spaces.feature +0 -9
- data/spec/gherkin/formatter/step_printer_spec.rb +0 -55
- data/spec/gherkin/formatter/tabs.feature +0 -9
- data/spec/gherkin/formatter/tag_count_formatter_spec.rb +0 -30
- data/spec/gherkin/i18n_spec.rb +0 -256
- data/spec/gherkin/java_lexer_spec.rb +0 -20
- data/spec/gherkin/json_parser_spec.rb +0 -165
- data/spec/gherkin/lexer/i18n_lexer_spec.rb +0 -65
- data/spec/gherkin/native_lexer_spec.rb +0 -29
- data/spec/gherkin/parser/parser_spec.rb +0 -16
- data/spec/gherkin/rubify_spec.rb +0 -23
- data/spec/gherkin/sexp_recorder.rb +0 -59
- data/spec/gherkin/shared/doc_string_group.rb +0 -161
- data/spec/gherkin/shared/encoding_group.rb +0 -48
- data/spec/gherkin/shared/lexer_group.rb +0 -589
- data/spec/gherkin/shared/row_group.rb +0 -123
- data/spec/gherkin/shared/tags_group.rb +0 -52
- data/spec/gherkin/tag_expression_spec.rb +0 -146
- data/spec/spec_helper.rb +0 -94
- data/tasks/apidoc.rake +0 -32
- data/tasks/bench.rake +0 -184
- data/tasks/bench/feature_builder.rb +0 -49
- data/tasks/bench/null_listener.rb +0 -4
- data/tasks/compile.rake +0 -83
- data/tasks/cucumber.rake +0 -23
- data/tasks/gems.rake +0 -46
- data/tasks/ikvm.rake +0 -126
- data/tasks/ragel_task.rb +0 -124
- data/tasks/release.rake +0 -34
- data/tasks/rspec.rake +0 -6
- data/tasks/yard/default/layout/html/bubble_32x32.png +0 -0
- data/tasks/yard/default/layout/html/bubble_48x48.png +0 -0
- data/tasks/yard/default/layout/html/footer.erb +0 -5
- data/tasks/yard/default/layout/html/index.erb +0 -1
- data/tasks/yard/default/layout/html/layout.erb +0 -25
- data/tasks/yard/default/layout/html/logo.erb +0 -1
- data/tasks/yard/default/layout/html/setup.rb +0 -4
@@ -1,123 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
module Gherkin
|
3
|
-
module Lexer
|
4
|
-
shared_examples_for "a Gherkin lexer lexing rows" do
|
5
|
-
def scan(gherkin)
|
6
|
-
@lexer.scan(gherkin)
|
7
|
-
end
|
8
|
-
|
9
|
-
rows = {
|
10
|
-
"|a|b|\n" => %w{a b},
|
11
|
-
"|a|b|c|\n" => %w{a b c},
|
12
|
-
}
|
13
|
-
|
14
|
-
rows.each do |text, expected|
|
15
|
-
it "should parse #{text}" do
|
16
|
-
@listener.should_receive(:row).with(r(expected), 1)
|
17
|
-
scan(text.dup)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
it "should parse a row with many cells" do
|
22
|
-
@listener.should_receive(:row).with(r(%w{a b c d e f g h i j k l m n o p}), 1)
|
23
|
-
scan("|a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|\n")
|
24
|
-
end
|
25
|
-
|
26
|
-
it "should parse multicharacter cell content" do
|
27
|
-
@listener.should_receive(:row).with(r(%w{foo bar}), 1)
|
28
|
-
scan("| foo | bar |\n")
|
29
|
-
end
|
30
|
-
|
31
|
-
it "should escape backslashed pipes" do
|
32
|
-
@listener.should_receive(:row).with(r(['|', 'the', '\a', '\\', '|\\|']), 1)
|
33
|
-
scan('| \| | the | \a | \\ | \|\\\| |' + "\n")
|
34
|
-
end
|
35
|
-
|
36
|
-
it "should parse cells with newlines" do
|
37
|
-
@listener.should_receive(:row).with(r(["\n"]), 1)
|
38
|
-
scan("|\\n|" + "\n")
|
39
|
-
end
|
40
|
-
|
41
|
-
it "should parse cells with spaces within the content" do
|
42
|
-
@listener.should_receive(:row).with(r(["Dill pickle", "Valencia orange"]), 1)
|
43
|
-
scan("| Dill pickle | Valencia orange |\n")
|
44
|
-
end
|
45
|
-
|
46
|
-
it "should allow utf-8" do
|
47
|
-
scan(" | ůﻚ | 2 | \n")
|
48
|
-
@listener.to_sexp.should == [
|
49
|
-
[:row, ["ůﻚ", "2"], 1],
|
50
|
-
[:eof]
|
51
|
-
]
|
52
|
-
end
|
53
|
-
|
54
|
-
it "should allow utf-8 using should_receive" do
|
55
|
-
@listener.should_receive(:row).with(r(['繁體中文 而且','並且','繁體中文 而且','並且']), 1)
|
56
|
-
scan("| 繁體中文 而且|並且| 繁體中文 而且|並且|\n")
|
57
|
-
end
|
58
|
-
|
59
|
-
it "should parse a 2x2 table" do
|
60
|
-
@listener.should_receive(:row).with(r(%w{1 2}), 1)
|
61
|
-
@listener.should_receive(:row).with(r(%w{3 4}), 2)
|
62
|
-
scan("| 1 | 2 |\n| 3 | 4 |\n")
|
63
|
-
end
|
64
|
-
|
65
|
-
it "should parse a 2x2 table with empty cells" do
|
66
|
-
@listener.should_receive(:row).with(r(['1', '']), 1)
|
67
|
-
@listener.should_receive(:row).with(r(['', '4']), 2)
|
68
|
-
scan("| 1 | |\n|| 4 |\n")
|
69
|
-
end
|
70
|
-
|
71
|
-
it "should parse a row with empty cells" do
|
72
|
-
@listener.should_receive(:row).with(r(['1', '']), 1).twice
|
73
|
-
scan("| 1 | |\n")
|
74
|
-
scan("|1||\n")
|
75
|
-
end
|
76
|
-
|
77
|
-
it "should parse a 1x2 table that does not end in a newline" do
|
78
|
-
@listener.should_receive(:row).with(r(%w{1 2}), 1)
|
79
|
-
scan("| 1 | 2 |")
|
80
|
-
end
|
81
|
-
|
82
|
-
it "should parse a row without spaces and with a newline" do
|
83
|
-
@listener.should_receive(:row).with(r(%w{1 2}), 1)
|
84
|
-
scan("|1|2|\n")
|
85
|
-
end
|
86
|
-
|
87
|
-
it "should parse a row with whitespace after the rows" do
|
88
|
-
@listener.should_receive(:row).with(r(%w{1 2}), 1)
|
89
|
-
scan("| 1 | 2 | \n ")
|
90
|
-
end
|
91
|
-
|
92
|
-
it "should parse a row with lots of whitespace" do
|
93
|
-
@listener.should_receive(:row).with(r(["abc", "123"]), 1)
|
94
|
-
scan(" \t| \t abc\t| \t123\t \t\t| \t\t \t \t\n ")
|
95
|
-
end
|
96
|
-
|
97
|
-
it "should parse a table with a commented-out row" do
|
98
|
-
@listener.should_receive(:row).with(r(["abc"]), 1)
|
99
|
-
@listener.should_receive(:comment).with("#|123|", 2)
|
100
|
-
@listener.should_receive(:row).with(r(["def"]), 3)
|
101
|
-
scan("|abc|\n#|123|\n|def|\n")
|
102
|
-
end
|
103
|
-
|
104
|
-
it "should raise LexingError for rows that aren't closed" do
|
105
|
-
lambda {
|
106
|
-
scan("|| oh hello \n")
|
107
|
-
}.should raise_error(/Lexing error on line 1: '\|\| oh hello/)
|
108
|
-
end
|
109
|
-
|
110
|
-
it "should raise LexingError for rows that are followed by a comment" do
|
111
|
-
lambda {
|
112
|
-
scan("|hi| # oh hello \n")
|
113
|
-
}.should raise_error(/Lexing error on line 1: '\|hi\| # oh hello/)
|
114
|
-
end
|
115
|
-
|
116
|
-
it "should raise LexingError for rows that aren't closed" do
|
117
|
-
lambda {
|
118
|
-
scan("|| oh hello \n |Shoudn't Get|Here|")
|
119
|
-
}.should raise_error(/Lexing error on line 1: '\|\| oh hello/)
|
120
|
-
end
|
121
|
-
end
|
122
|
-
end
|
123
|
-
end
|
@@ -1,52 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
module Gherkin
|
3
|
-
module Lexer
|
4
|
-
shared_examples_for "a Gherkin lexer lexing tags" do
|
5
|
-
def scan(gherkin)
|
6
|
-
@lexer.scan(gherkin)
|
7
|
-
end
|
8
|
-
|
9
|
-
it "should lex a single tag" do
|
10
|
-
@listener.should_receive(:tag).with("@dog", 1)
|
11
|
-
scan("@dog\n")
|
12
|
-
end
|
13
|
-
|
14
|
-
it "should lex multiple tags" do
|
15
|
-
@listener.should_receive(:tag).twice
|
16
|
-
scan("@dog @cat\n")
|
17
|
-
end
|
18
|
-
|
19
|
-
it "should lex UTF-8 tags" do
|
20
|
-
@listener.should_receive(:tag).with("@シナリオテンプレート", 1)
|
21
|
-
scan("@シナリオテンプレート\n")
|
22
|
-
end
|
23
|
-
|
24
|
-
it "should lex mixed tags" do
|
25
|
-
@listener.should_receive(:tag).with("@wip", 1).ordered
|
26
|
-
@listener.should_receive(:tag).with("@Значения", 1).ordered
|
27
|
-
scan("@wip @Значения\n")
|
28
|
-
end
|
29
|
-
|
30
|
-
it "should lex wacky identifiers" do
|
31
|
-
@listener.should_receive(:tag).exactly(4).times
|
32
|
-
scan("@BJ-x98.77 @BJ-z12.33 @O_o" "@#not_a_comment\n")
|
33
|
-
end
|
34
|
-
|
35
|
-
# TODO: Ask on ML for opinions about this one
|
36
|
-
it "should lex tags without spaces between them?" do
|
37
|
-
@listener.should_receive(:tag).twice
|
38
|
-
scan("@one@two\n")
|
39
|
-
end
|
40
|
-
|
41
|
-
it "should not lex tags beginning with two @@ signs" do
|
42
|
-
@listener.should_not_receive(:tag)
|
43
|
-
lambda { scan("@@test\n") }.should raise_error(/Lexing error on line 1/)
|
44
|
-
end
|
45
|
-
|
46
|
-
it "should not lex a lone @ sign" do
|
47
|
-
@listener.should_not_receive(:tag)
|
48
|
-
lambda { scan("@\n") }.should raise_error(/Lexing error on line 1/)
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
@@ -1,146 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'gherkin/tag_expression'
|
3
|
-
require 'gherkin/formatter/model'
|
4
|
-
|
5
|
-
module Gherkin
|
6
|
-
describe TagExpression do
|
7
|
-
def tag(name)
|
8
|
-
Formatter::Model::Tag.new(name, 0)
|
9
|
-
end
|
10
|
-
|
11
|
-
context "no tags" do
|
12
|
-
before(:each) do
|
13
|
-
@e = Gherkin::TagExpression.new([])
|
14
|
-
end
|
15
|
-
|
16
|
-
it 'should be empty' do
|
17
|
-
@e.should be_empty
|
18
|
-
end
|
19
|
-
|
20
|
-
it "should match @foo" do
|
21
|
-
@e.evaluate([tag('@foo')]).should == true
|
22
|
-
end
|
23
|
-
|
24
|
-
it "should match empty tags" do
|
25
|
-
@e.evaluate([]).should == true
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
context "@foo" do
|
30
|
-
before(:each) do
|
31
|
-
@e = Gherkin::TagExpression.new(['@foo'])
|
32
|
-
end
|
33
|
-
|
34
|
-
it "should match @foo" do
|
35
|
-
@e.evaluate([tag('@foo')]).should == true
|
36
|
-
end
|
37
|
-
|
38
|
-
it "should not match @bar" do
|
39
|
-
@e.evaluate([tag('@bar')]).should == false
|
40
|
-
end
|
41
|
-
|
42
|
-
it "should not match no tags" do
|
43
|
-
@e.evaluate([]).should == false
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
context "!@foo" do
|
48
|
-
before(:each) do
|
49
|
-
@e = Gherkin::TagExpression.new(['~@foo'])
|
50
|
-
end
|
51
|
-
|
52
|
-
it "should match @bar" do
|
53
|
-
@e.evaluate([tag('@bar')]).should == true
|
54
|
-
end
|
55
|
-
|
56
|
-
it "should not match @foo" do
|
57
|
-
@e.evaluate([tag('@foo')]).should == false
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
context "@foo || @bar" do
|
62
|
-
before(:each) do
|
63
|
-
@e = Gherkin::TagExpression.new(['@foo,@bar'])
|
64
|
-
end
|
65
|
-
|
66
|
-
it "should match @foo" do
|
67
|
-
@e.evaluate([tag('@foo')]).should == true
|
68
|
-
end
|
69
|
-
|
70
|
-
it "should match @bar" do
|
71
|
-
@e.evaluate([tag('@bar')]).should == true
|
72
|
-
end
|
73
|
-
|
74
|
-
it "should not match @zap" do
|
75
|
-
@e.evaluate([tag('@zap')]).should == false
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
context "(@foo || @bar) && !@zap" do
|
80
|
-
before(:each) do
|
81
|
-
@e = Gherkin::TagExpression.new(['@foo,@bar', '~@zap'])
|
82
|
-
end
|
83
|
-
|
84
|
-
it "should match @foo" do
|
85
|
-
@e.evaluate([tag('@foo')]).should == true
|
86
|
-
end
|
87
|
-
|
88
|
-
it "should not match @foo @zap" do
|
89
|
-
@e.evaluate([tag('@foo'), tag('@zap')]).should == false
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
93
|
-
context "(@foo:3 || !@bar:4) && @zap:5" do
|
94
|
-
before(:each) do
|
95
|
-
@e = Gherkin::TagExpression.new(['@foo:3,~@bar','@zap:5'])
|
96
|
-
end
|
97
|
-
|
98
|
-
it "should count tags for positive tags" do
|
99
|
-
rubify_hash(@e.limits).should == {'@foo' => 3, '@zap' => 5}
|
100
|
-
end
|
101
|
-
|
102
|
-
it "should match @foo @zap" do
|
103
|
-
@e.evaluate([tag('@foo'), tag('@zap')]).should == true
|
104
|
-
end
|
105
|
-
end
|
106
|
-
|
107
|
-
context "Parsing '@foo:3,~@bar', '@zap:5'" do
|
108
|
-
before(:each) do
|
109
|
-
@e = Gherkin::TagExpression.new([' @foo:3 , ~@bar ', ' @zap:5 '])
|
110
|
-
end
|
111
|
-
|
112
|
-
unless defined?(JRUBY_VERSION)
|
113
|
-
it "should split and trim (ruby implementation detail)" do
|
114
|
-
@e.__send__(:ruby_expression).should == "(!vars['@bar']||vars['@foo'])&&(vars['@zap'])"
|
115
|
-
end
|
116
|
-
end
|
117
|
-
|
118
|
-
it "should have limits" do
|
119
|
-
rubify_hash(@e.limits).should == {"@zap"=>5, "@foo"=>3}
|
120
|
-
end
|
121
|
-
end
|
122
|
-
|
123
|
-
context "Tag limits" do
|
124
|
-
it "should be counted for negative tags" do
|
125
|
-
@e = Gherkin::TagExpression.new(['~@todo:3'])
|
126
|
-
rubify_hash(@e.limits).should == {"@todo"=>3}
|
127
|
-
end
|
128
|
-
|
129
|
-
it "should be counted for positive tags" do
|
130
|
-
@e = Gherkin::TagExpression.new(['@todo:3'])
|
131
|
-
rubify_hash(@e.limits).should == {"@todo"=>3}
|
132
|
-
end
|
133
|
-
|
134
|
-
it "should raise an error for inconsistent limits" do
|
135
|
-
lambda do
|
136
|
-
@e = Gherkin::TagExpression.new(['@todo:3', '~@todo:4'])
|
137
|
-
end.should raise_error(/Inconsistent tag limits for @todo: 3 and 4/)
|
138
|
-
end
|
139
|
-
|
140
|
-
it "should allow duplicate consistent limits" do
|
141
|
-
@e = Gherkin::TagExpression.new(['@todo:3', '~@todo:3'])
|
142
|
-
rubify_hash(@e.limits).should == {"@todo"=>3}
|
143
|
-
end
|
144
|
-
end
|
145
|
-
end
|
146
|
-
end
|
data/spec/spec_helper.rb
DELETED
@@ -1,94 +0,0 @@
|
|
1
|
-
def silence_warnings(&block)
|
2
|
-
warn_level = $VERBOSE
|
3
|
-
$VERBOSE = nil
|
4
|
-
result = block.call
|
5
|
-
$VERBOSE = warn_level
|
6
|
-
result
|
7
|
-
end
|
8
|
-
|
9
|
-
if RUBY_VERSION =~ /1\.9|2\.0/
|
10
|
-
silence_warnings do
|
11
|
-
Encoding.default_external = Encoding::UTF_8
|
12
|
-
Encoding.default_internal = Encoding::UTF_8
|
13
|
-
end
|
14
|
-
end
|
15
|
-
if defined?(JRUBY_VERSION)
|
16
|
-
java_import java.util.ArrayList
|
17
|
-
ArrayList.__persistent__ = true
|
18
|
-
end
|
19
|
-
|
20
|
-
require 'rubygems'
|
21
|
-
require 'bundler'
|
22
|
-
Bundler.setup
|
23
|
-
|
24
|
-
require 'rspec'
|
25
|
-
require 'gherkin'
|
26
|
-
require 'stringio'
|
27
|
-
require 'gherkin/sexp_recorder'
|
28
|
-
require 'gherkin/shared/encoding_group'
|
29
|
-
require 'gherkin/shared/lexer_group'
|
30
|
-
require 'gherkin/shared/tags_group'
|
31
|
-
require 'gherkin/shared/doc_string_group'
|
32
|
-
require 'gherkin/shared/row_group'
|
33
|
-
require 'gherkin/lexer/encoding'
|
34
|
-
$:.unshift(File.dirname(__FILE__))
|
35
|
-
|
36
|
-
module GherkinSpecHelper
|
37
|
-
def scan_file(file)
|
38
|
-
@lexer.scan(fixture(file))
|
39
|
-
end
|
40
|
-
|
41
|
-
def fixture(file)
|
42
|
-
encoding = Gherkin::Lexer::Encoding.new
|
43
|
-
encoding.read_file(File.dirname(__FILE__) + "/gherkin/fixtures/" + file)
|
44
|
-
end
|
45
|
-
|
46
|
-
def rubify_hash(hash)
|
47
|
-
if defined?(JRUBY_VERSION)
|
48
|
-
h = {}
|
49
|
-
hash.keySet.each{|key| h[key] = hash[key]}
|
50
|
-
h
|
51
|
-
else
|
52
|
-
hash
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
RSpec.configure do |c|
|
58
|
-
c.include(GherkinSpecHelper)
|
59
|
-
end
|
60
|
-
|
61
|
-
# Allows comparison of Java List with Ruby Array (rows)
|
62
|
-
RSpec::Matchers.define :r do |expected|
|
63
|
-
match do |row|
|
64
|
-
silence_warnings do
|
65
|
-
def row.inspect
|
66
|
-
"r " + self.map{|cell| cell}.inspect
|
67
|
-
end
|
68
|
-
end
|
69
|
-
row.map{|cell| cell}.should == expected
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
RSpec::Matchers.define :a do |expected|
|
74
|
-
match do |array|
|
75
|
-
silence_warnings do
|
76
|
-
def array.inspect
|
77
|
-
"a " + self.map{|e| e.to_sym}.inspect
|
78
|
-
end
|
79
|
-
end
|
80
|
-
array.map{|e| e.to_sym}.should == expected
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
RSpec::Matchers.define :sym do |expected|
|
85
|
-
match do |actual|
|
86
|
-
expected.to_s == actual.to_s
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
RSpec::Matchers.define :allow do |event|
|
91
|
-
match do |parser|
|
92
|
-
parser.expected.index(event)
|
93
|
-
end
|
94
|
-
end
|
data/tasks/apidoc.rake
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
unless ENV['RUBY_CC_VERSION'] || defined?(JRUBY_VERSION)
|
2
|
-
require 'yard'
|
3
|
-
require 'yard/rake/yardoc_task'
|
4
|
-
|
5
|
-
SITE_DIR = File.expand_path(File.dirname(__FILE__) + '/../../cucumber.github.com')
|
6
|
-
API_DIR = File.join(SITE_DIR, 'api', 'gherkin', GHERKIN_VERSION)
|
7
|
-
|
8
|
-
namespace :api do
|
9
|
-
file :dir do
|
10
|
-
raise "You need to git clone git@github.com:cucumber/cucumber.github.com.git #{SITE_DIR}" unless File.directory?(SITE_DIR)
|
11
|
-
mkdir_p API_DIR
|
12
|
-
end
|
13
|
-
|
14
|
-
YARD::Templates::Engine.register_template_path(File.expand_path(File.join(File.dirname(__FILE__), 'yard')))
|
15
|
-
YARD::Rake::YardocTask.new(:yard) do |yard|
|
16
|
-
dir = File.join(API_DIR, 'ruby')
|
17
|
-
mkdir_p dir
|
18
|
-
yard.options = ["--out", dir]
|
19
|
-
end
|
20
|
-
task :yard => :dir
|
21
|
-
|
22
|
-
task :mvn_javadoc => :dir do
|
23
|
-
Dir.chdir('java') do
|
24
|
-
sh("mvn javadoc:javadoc")
|
25
|
-
dir = File.join(API_DIR, 'java')
|
26
|
-
mv 'target/site/apidocs', dir
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
task :doc => [:mvn_javadoc, :yard]
|
31
|
-
end
|
32
|
-
end
|