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,150 +0,0 @@
|
|
1
|
-
require 'gherkin/tag_expression'
|
2
|
-
require 'gherkin/formatter/regexp_filter'
|
3
|
-
require 'gherkin/formatter/line_filter'
|
4
|
-
require 'gherkin/formatter/tag_filter'
|
5
|
-
require 'gherkin/formatter/model'
|
6
|
-
require 'gherkin/native'
|
7
|
-
|
8
|
-
module Gherkin
|
9
|
-
module Formatter
|
10
|
-
class FilterFormatter
|
11
|
-
native_impl('gherkin')
|
12
|
-
|
13
|
-
def initialize(formatter, filters)
|
14
|
-
@formatter = formatter
|
15
|
-
@filter = detect_filter(filters)
|
16
|
-
|
17
|
-
@feature_tags = []
|
18
|
-
@feature_element_tags = []
|
19
|
-
@examples_tags = []
|
20
|
-
@examples_range = []
|
21
|
-
@feature_events = []
|
22
|
-
@background_events = []
|
23
|
-
@feature_element_events = []
|
24
|
-
@examples_events = []
|
25
|
-
|
26
|
-
@examples_name = nil
|
27
|
-
@feature_element_name = nil
|
28
|
-
@feature_element_range = nil
|
29
|
-
end
|
30
|
-
|
31
|
-
def uri(uri)
|
32
|
-
@formatter.uri(uri)
|
33
|
-
end
|
34
|
-
|
35
|
-
def feature(feature)
|
36
|
-
@feature_tags = feature.tags
|
37
|
-
@feature_name = feature.name
|
38
|
-
@feature_events = [feature]
|
39
|
-
end
|
40
|
-
|
41
|
-
def background(background)
|
42
|
-
@feature_element_name = background.name
|
43
|
-
@feature_element_range = background.line_range
|
44
|
-
@background_events = [background]
|
45
|
-
end
|
46
|
-
|
47
|
-
def scenario(scenario)
|
48
|
-
replay!
|
49
|
-
@feature_element_tags = scenario.tags
|
50
|
-
@feature_element_name = scenario.name
|
51
|
-
@feature_element_range = scenario.line_range
|
52
|
-
@feature_element_events = [scenario]
|
53
|
-
end
|
54
|
-
|
55
|
-
def scenario_outline(scenario_outline)
|
56
|
-
replay!
|
57
|
-
@feature_element_tags = scenario_outline.tags
|
58
|
-
@feature_element_name = scenario_outline.name
|
59
|
-
@feature_element_range = scenario_outline.line_range
|
60
|
-
@feature_element_events = [scenario_outline]
|
61
|
-
end
|
62
|
-
|
63
|
-
def examples(examples)
|
64
|
-
replay!
|
65
|
-
@examples_tags = examples.tags
|
66
|
-
@examples_name = examples.name
|
67
|
-
|
68
|
-
table_body_range = case(examples.rows.length)
|
69
|
-
when 0 then examples.line_range.last..examples.line_range.last
|
70
|
-
when 1 then examples.rows[0].line..examples.rows[0].line
|
71
|
-
else examples.rows[1].line..examples.rows[-1].line
|
72
|
-
end
|
73
|
-
|
74
|
-
@examples_range = examples.line_range.first..table_body_range.last
|
75
|
-
if(@filter.evaluate([], [], [table_body_range]))
|
76
|
-
examples.rows = @filter.filter_table_body_rows(examples.rows)
|
77
|
-
end
|
78
|
-
@examples_events = [examples]
|
79
|
-
end
|
80
|
-
|
81
|
-
def step(step)
|
82
|
-
if @feature_element_events.any?
|
83
|
-
@feature_element_events << step
|
84
|
-
else
|
85
|
-
@background_events << step
|
86
|
-
end
|
87
|
-
|
88
|
-
@feature_element_range = @feature_element_range.first..step.line_range.last
|
89
|
-
end
|
90
|
-
|
91
|
-
def eof
|
92
|
-
replay!
|
93
|
-
@formatter.eof
|
94
|
-
end
|
95
|
-
|
96
|
-
def done
|
97
|
-
@formatter.done
|
98
|
-
end
|
99
|
-
|
100
|
-
private
|
101
|
-
|
102
|
-
def detect_filter(filters)
|
103
|
-
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
|
104
|
-
case(filters[0])
|
105
|
-
when Fixnum
|
106
|
-
LineFilter.new(filters)
|
107
|
-
when Regexp
|
108
|
-
RegexpFilter.new(filters)
|
109
|
-
when String
|
110
|
-
TagFilter.new(filters)
|
111
|
-
end
|
112
|
-
end
|
113
|
-
|
114
|
-
def replay!
|
115
|
-
feature_element_ok = @filter.evaluate(
|
116
|
-
(@feature_tags + @feature_element_tags),
|
117
|
-
[@feature_name, @feature_element_name].compact,
|
118
|
-
[@feature_element_range].compact
|
119
|
-
)
|
120
|
-
examples_ok = @filter.evaluate(
|
121
|
-
(@feature_tags + @feature_element_tags + @examples_tags),
|
122
|
-
[@feature_name, @feature_element_name, @examples_name].compact,
|
123
|
-
[@feature_element_range, @examples_range].compact
|
124
|
-
)
|
125
|
-
|
126
|
-
if feature_element_ok || examples_ok
|
127
|
-
replay_events!(@feature_events)
|
128
|
-
replay_events!(@background_events)
|
129
|
-
replay_events!(@feature_element_events)
|
130
|
-
|
131
|
-
if examples_ok
|
132
|
-
replay_events!(@examples_events)
|
133
|
-
end
|
134
|
-
end
|
135
|
-
|
136
|
-
@examples_events.clear
|
137
|
-
@examples_tags = []
|
138
|
-
@examples_name = nil
|
139
|
-
@examples_range = nil
|
140
|
-
end
|
141
|
-
|
142
|
-
def replay_events!(events)
|
143
|
-
events.each do |event|
|
144
|
-
event.replay(@formatter)
|
145
|
-
end
|
146
|
-
events.clear
|
147
|
-
end
|
148
|
-
end
|
149
|
-
end
|
150
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
module Gherkin
|
2
|
-
module Formatter
|
3
|
-
class Hashable
|
4
|
-
def to_hash
|
5
|
-
ivars = instance_variables
|
6
|
-
# When tests are runn with therubyracer (JavaScript), an extra field might
|
7
|
-
# exist - added by Ref::WeakReference
|
8
|
-
# https://github.com/bdurand/ref/blob/master/lib/ref/weak_reference/pure_ruby.rb
|
9
|
-
# Remove it - we don't want it in the JSON.
|
10
|
-
ivars.delete(:@__weak_backreferences__)
|
11
|
-
ivars.inject({}) do |hash, ivar|
|
12
|
-
value = instance_variable_get(ivar)
|
13
|
-
value = value.to_hash if value.respond_to?(:to_hash)
|
14
|
-
if Array === value
|
15
|
-
value = value.map do |e|
|
16
|
-
e.respond_to?(:to_hash) ? e.to_hash : e
|
17
|
-
end
|
18
|
-
end
|
19
|
-
hash[ivar[1..-1]] = value unless [[], nil].index(value)
|
20
|
-
hash
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
@@ -1,133 +0,0 @@
|
|
1
|
-
require 'multi_json'
|
2
|
-
require 'gherkin/formatter/model'
|
3
|
-
require 'gherkin/native'
|
4
|
-
require 'base64'
|
5
|
-
|
6
|
-
module Gherkin
|
7
|
-
module Formatter
|
8
|
-
# This class doesn't really generate JSON - instead it populates an Array that can easily
|
9
|
-
# be turned into JSON.
|
10
|
-
class JSONFormatter
|
11
|
-
native_impl('gherkin')
|
12
|
-
|
13
|
-
include Base64
|
14
|
-
|
15
|
-
def initialize(io)
|
16
|
-
raise "Must be writeable" unless io.respond_to?(:write)
|
17
|
-
@io = io
|
18
|
-
@feature_hashes = []
|
19
|
-
@current_step_or_hook = nil
|
20
|
-
end
|
21
|
-
|
22
|
-
def done
|
23
|
-
@io.write(MultiJson.dump(@feature_hashes, :pretty => true))
|
24
|
-
end
|
25
|
-
|
26
|
-
def uri(uri)
|
27
|
-
@uri = uri
|
28
|
-
end
|
29
|
-
|
30
|
-
def feature(feature)
|
31
|
-
@feature_hash = feature.to_hash
|
32
|
-
@feature_hash['uri'] = @uri
|
33
|
-
@feature_hashes << @feature_hash
|
34
|
-
end
|
35
|
-
|
36
|
-
def background(background)
|
37
|
-
feature_elements << background.to_hash
|
38
|
-
end
|
39
|
-
|
40
|
-
def scenario(scenario)
|
41
|
-
feature_elements << scenario.to_hash
|
42
|
-
end
|
43
|
-
|
44
|
-
def scenario_outline(scenario_outline)
|
45
|
-
feature_elements << scenario_outline.to_hash
|
46
|
-
end
|
47
|
-
|
48
|
-
def examples(examples)
|
49
|
-
all_examples << examples.to_hash
|
50
|
-
end
|
51
|
-
|
52
|
-
def step(step)
|
53
|
-
@current_step_or_hook = step.to_hash
|
54
|
-
steps << @current_step_or_hook
|
55
|
-
end
|
56
|
-
|
57
|
-
def match(match)
|
58
|
-
@current_step_or_hook['match'] = match.to_hash
|
59
|
-
end
|
60
|
-
|
61
|
-
def result(result)
|
62
|
-
@current_step_or_hook['result'] = result.to_hash
|
63
|
-
end
|
64
|
-
|
65
|
-
def append_duration(timestamp)
|
66
|
-
#check to make sure result exists (scenario outlines do not have results yet)
|
67
|
-
if !@current_step_or_hook['result'].nil?
|
68
|
-
#convert to nanoseconds
|
69
|
-
timestamp = timestamp * 1000000000
|
70
|
-
rshash = @current_step_or_hook['result'].to_hash
|
71
|
-
rshash['duration'] = timestamp.to_i
|
72
|
-
@current_step_or_hook['result'] = rshash
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
def before(match, result)
|
77
|
-
add_hook(match, result, "before")
|
78
|
-
end
|
79
|
-
|
80
|
-
def after(match, result)
|
81
|
-
add_hook(match, result, "after")
|
82
|
-
end
|
83
|
-
|
84
|
-
def embedding(mime_type, data)
|
85
|
-
embeddings << {'mime_type' => mime_type, 'data' => encode64s(data)}
|
86
|
-
end
|
87
|
-
|
88
|
-
def write(text)
|
89
|
-
output << text
|
90
|
-
end
|
91
|
-
|
92
|
-
def eof
|
93
|
-
end
|
94
|
-
|
95
|
-
private
|
96
|
-
|
97
|
-
def add_hook(match, result, hook)
|
98
|
-
hooks = feature_element[hook] ||= []
|
99
|
-
hooks << {'match' => match.to_hash, 'result' => result.to_hash}
|
100
|
-
end
|
101
|
-
|
102
|
-
def feature_elements
|
103
|
-
@feature_hash['elements'] ||= []
|
104
|
-
end
|
105
|
-
|
106
|
-
def feature_element
|
107
|
-
feature_elements[-1]
|
108
|
-
end
|
109
|
-
|
110
|
-
def all_examples
|
111
|
-
feature_element['examples'] ||= []
|
112
|
-
end
|
113
|
-
|
114
|
-
def steps
|
115
|
-
feature_element['steps'] ||= []
|
116
|
-
end
|
117
|
-
|
118
|
-
def embeddings
|
119
|
-
@current_step_or_hook['embeddings'] ||= []
|
120
|
-
end
|
121
|
-
|
122
|
-
def output
|
123
|
-
@current_step_or_hook['output'] ||= []
|
124
|
-
end
|
125
|
-
|
126
|
-
def encode64s(data)
|
127
|
-
# Strip newlines
|
128
|
-
Base64.encode64(data).gsub(/\n/, '')
|
129
|
-
end
|
130
|
-
end
|
131
|
-
end
|
132
|
-
end
|
133
|
-
|
@@ -1,26 +0,0 @@
|
|
1
|
-
module Gherkin
|
2
|
-
module Formatter
|
3
|
-
class LineFilter
|
4
|
-
def initialize(lines)
|
5
|
-
@lines = lines
|
6
|
-
end
|
7
|
-
|
8
|
-
def evaluate(tags, names, ranges)
|
9
|
-
ranges.detect do |range|
|
10
|
-
@lines.detect do |line|
|
11
|
-
range.include?(line)
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
def filter_table_body_rows(rows)
|
17
|
-
body = rows.to_a[1..-1].select do |row|
|
18
|
-
@lines.detect do |line|
|
19
|
-
row.line == line
|
20
|
-
end
|
21
|
-
end
|
22
|
-
[rows[0]] + body
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
@@ -1,281 +0,0 @@
|
|
1
|
-
require 'gherkin/native'
|
2
|
-
require 'gherkin/formatter/hashable'
|
3
|
-
|
4
|
-
module Gherkin
|
5
|
-
module Formatter
|
6
|
-
module Model
|
7
|
-
class BasicStatement < Hashable
|
8
|
-
attr_reader :comments, :keyword, :name, :line
|
9
|
-
|
10
|
-
def initialize(comments, keyword, name, line)
|
11
|
-
@comments, @keyword, @name, @line = comments, keyword, name, line
|
12
|
-
end
|
13
|
-
|
14
|
-
def line_range
|
15
|
-
first = @comments.any? ? @comments[0].line : first_non_comment_line
|
16
|
-
first..line
|
17
|
-
end
|
18
|
-
|
19
|
-
def first_non_comment_line
|
20
|
-
@line
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
class DescribedStatement < BasicStatement
|
25
|
-
attr_reader :description
|
26
|
-
|
27
|
-
def initialize(comments, keyword, name, description, line)
|
28
|
-
super(comments, keyword, name, line)
|
29
|
-
@description = description
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
class TagStatement < DescribedStatement
|
34
|
-
attr_reader :tags, :id
|
35
|
-
|
36
|
-
def initialize(comments, tags, keyword, name, description, line, id)
|
37
|
-
super(comments, keyword, name, description, line)
|
38
|
-
@tags = tags
|
39
|
-
@id = id
|
40
|
-
end
|
41
|
-
|
42
|
-
def first_non_comment_line
|
43
|
-
@tags.any? ? @tags[0].line : @line
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
class Feature < TagStatement
|
48
|
-
native_impl('gherkin')
|
49
|
-
|
50
|
-
def replay(formatter)
|
51
|
-
formatter.feature(self)
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
class Background < DescribedStatement
|
56
|
-
native_impl('gherkin')
|
57
|
-
|
58
|
-
def initialize(comments, keyword, name, description, line)
|
59
|
-
super(comments, keyword, name, description, line)
|
60
|
-
@type = "background"
|
61
|
-
end
|
62
|
-
|
63
|
-
def replay(formatter)
|
64
|
-
formatter.background(self)
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
class Scenario < TagStatement
|
69
|
-
native_impl('gherkin')
|
70
|
-
|
71
|
-
def initialize(comments, tags, keyword, name, description, line, id)
|
72
|
-
super(comments, tags, keyword, name, description, line, id)
|
73
|
-
@type = "scenario"
|
74
|
-
end
|
75
|
-
|
76
|
-
def replay(formatter)
|
77
|
-
formatter.scenario(self)
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
class ScenarioOutline < TagStatement
|
82
|
-
native_impl('gherkin')
|
83
|
-
|
84
|
-
def initialize(comments, tags, keyword, name, description, line, id)
|
85
|
-
super(comments, tags, keyword, name, description, line, id)
|
86
|
-
@type = "scenario_outline"
|
87
|
-
end
|
88
|
-
|
89
|
-
def replay(formatter)
|
90
|
-
formatter.scenario_outline(self)
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
class Examples < TagStatement
|
95
|
-
native_impl('gherkin')
|
96
|
-
|
97
|
-
attr_accessor :rows # needs to remain mutable for filters
|
98
|
-
|
99
|
-
def initialize(comments, tags, keyword, name, description, line, id, rows)
|
100
|
-
super(comments, tags, keyword, name, description, line, id)
|
101
|
-
@rows = rows
|
102
|
-
end
|
103
|
-
|
104
|
-
def replay(formatter)
|
105
|
-
formatter.examples(self)
|
106
|
-
end
|
107
|
-
|
108
|
-
class Builder
|
109
|
-
def initialize(*args)
|
110
|
-
@args = *args
|
111
|
-
@rows = nil
|
112
|
-
end
|
113
|
-
|
114
|
-
def row(comments, cells, line, id)
|
115
|
-
@rows ||= []
|
116
|
-
@rows << ExamplesTableRow.new(comments, cells, line, id)
|
117
|
-
end
|
118
|
-
|
119
|
-
def replay(formatter)
|
120
|
-
build.replay(formatter)
|
121
|
-
end
|
122
|
-
|
123
|
-
def build
|
124
|
-
Examples.new(*(@args << @rows))
|
125
|
-
end
|
126
|
-
end
|
127
|
-
end
|
128
|
-
|
129
|
-
class Step < BasicStatement
|
130
|
-
native_impl('gherkin')
|
131
|
-
|
132
|
-
attr_reader :rows, :doc_string
|
133
|
-
|
134
|
-
def initialize(comments, keyword, name, line, rows, doc_string)
|
135
|
-
super(comments, keyword, name, line)
|
136
|
-
@rows, @doc_string = rows, doc_string
|
137
|
-
end
|
138
|
-
|
139
|
-
def line_range
|
140
|
-
range = super
|
141
|
-
if(rows)
|
142
|
-
range = range.first..rows[-1].line
|
143
|
-
elsif(doc_string)
|
144
|
-
range = range.first..doc_string.line_range.last
|
145
|
-
end
|
146
|
-
range
|
147
|
-
end
|
148
|
-
|
149
|
-
def replay(formatter)
|
150
|
-
formatter.step(self)
|
151
|
-
end
|
152
|
-
|
153
|
-
def outline_args
|
154
|
-
offset = 0
|
155
|
-
name.scan(/<[^<]*>/).map do |val|
|
156
|
-
offset = name.index(val, offset)
|
157
|
-
Argument.new(offset, val)
|
158
|
-
end
|
159
|
-
end
|
160
|
-
|
161
|
-
class Builder
|
162
|
-
def initialize(*args)
|
163
|
-
@args = *args
|
164
|
-
@rows = nil
|
165
|
-
@doc_string = nil
|
166
|
-
end
|
167
|
-
|
168
|
-
def row(comments, cells, line, id)
|
169
|
-
@rows ||= []
|
170
|
-
@rows << DataTableRow.new(comments, cells, line)
|
171
|
-
end
|
172
|
-
|
173
|
-
def doc_string(string, content_type, line)
|
174
|
-
@doc_string = Formatter::Model::DocString.new(string, content_type, line)
|
175
|
-
end
|
176
|
-
|
177
|
-
def replay(formatter)
|
178
|
-
build.replay(formatter)
|
179
|
-
end
|
180
|
-
|
181
|
-
def build
|
182
|
-
Step.new(*(@args << @rows << @doc_string))
|
183
|
-
end
|
184
|
-
end
|
185
|
-
end
|
186
|
-
|
187
|
-
class Comment < Hashable
|
188
|
-
native_impl('gherkin')
|
189
|
-
|
190
|
-
attr_reader :value, :line
|
191
|
-
|
192
|
-
def initialize(value, line)
|
193
|
-
@value, @line = value, line
|
194
|
-
end
|
195
|
-
end
|
196
|
-
|
197
|
-
class Tag < Hashable
|
198
|
-
native_impl('gherkin')
|
199
|
-
|
200
|
-
attr_reader :name, :line
|
201
|
-
|
202
|
-
def initialize(name, line)
|
203
|
-
@name, @line = name, line
|
204
|
-
end
|
205
|
-
|
206
|
-
def eql?(tag)
|
207
|
-
@name.eql?(tag.name)
|
208
|
-
end
|
209
|
-
|
210
|
-
def hash
|
211
|
-
@name.hash
|
212
|
-
end
|
213
|
-
end
|
214
|
-
|
215
|
-
class DocString < Hashable
|
216
|
-
native_impl('gherkin')
|
217
|
-
|
218
|
-
attr_reader :value, :content_type, :line
|
219
|
-
|
220
|
-
def initialize(value, content_type, line)
|
221
|
-
@value, @content_type, @line = value, content_type, line
|
222
|
-
end
|
223
|
-
|
224
|
-
def line_range
|
225
|
-
line_count = value.split(/\r?\n/).length
|
226
|
-
line..(line+line_count+1)
|
227
|
-
end
|
228
|
-
end
|
229
|
-
|
230
|
-
class Row < Hashable
|
231
|
-
attr_reader :comments, :cells, :line
|
232
|
-
|
233
|
-
def initialize(comments, cells, line)
|
234
|
-
@comments, @cells, @line = comments, cells, line
|
235
|
-
end
|
236
|
-
end
|
237
|
-
|
238
|
-
class DataTableRow < Row
|
239
|
-
native_impl('gherkin')
|
240
|
-
end
|
241
|
-
|
242
|
-
class ExamplesTableRow < Row
|
243
|
-
native_impl('gherkin')
|
244
|
-
attr_reader :id
|
245
|
-
|
246
|
-
def initialize(comments, cells, line, id)
|
247
|
-
super(comments, cells, line)
|
248
|
-
@id = id
|
249
|
-
end
|
250
|
-
end
|
251
|
-
|
252
|
-
class Match < Hashable
|
253
|
-
native_impl('gherkin')
|
254
|
-
|
255
|
-
attr_reader :arguments, :location
|
256
|
-
|
257
|
-
def initialize(arguments, location)
|
258
|
-
@arguments, @location = arguments, location
|
259
|
-
end
|
260
|
-
|
261
|
-
def replay(formatter)
|
262
|
-
formatter.match(self)
|
263
|
-
end
|
264
|
-
end
|
265
|
-
|
266
|
-
class Result < Hashable
|
267
|
-
native_impl('gherkin')
|
268
|
-
|
269
|
-
attr_reader :status, :duration, :error_message
|
270
|
-
|
271
|
-
def initialize(status, duration, error_message)
|
272
|
-
@status, @duration, @error_message = status, duration, error_message
|
273
|
-
end
|
274
|
-
|
275
|
-
def replay(formatter)
|
276
|
-
formatter.result(self)
|
277
|
-
end
|
278
|
-
end
|
279
|
-
end
|
280
|
-
end
|
281
|
-
end
|