Last active
November 3, 2018 20:05
-
-
Save enkessler/255982d36d4ea8f61b4f5d724998671b to your computer and use it in GitHub Desktop.
Custom gherkin dialect
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'gherkin/gherkin' | |
require 'gherkin/dialect' | |
test_dialects = JSON.parse(File.open('test_languages.json', 'r:UTF-8').read) | |
Gherkin::DIALECTS.merge!(test_dialects) | |
source_text = File.read('something_to_parse.feature') | |
result = Gherkin::Gherkin.from_source('junk_file_name', source_text, {default_dialect: 'cm-test'}).to_a | |
puts "messages returned: #{result.count}" | |
puts "messages: #{result}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# feature comment | |
@tag1 @tag2 @tag3 | |
CM-Feature: A feature with everything it could have | |
Including a description | |
and then some. | |
# background comment | |
CM-Background: | |
Background | |
description | |
CM-* a step | |
# table comment | |
| value1 | | |
# table row comment | |
| value2 | | |
CM-* another step | |
# scenario comment | |
@scenario_tag | |
CM-Scenario: | |
Scenario | |
description | |
CM-* a step | |
CM-* another step | |
""" | |
some text | |
""" | |
# outline comment | |
@outline_tag | |
CM-Scenario Outline: | |
Outline | |
description | |
# step comment | |
CM-* a step | |
# table comment | |
| value2 | | |
# step comment | |
CM-* another step | |
# doc string comment | |
""" | |
some text | |
""" | |
# example comment | |
@example_tag | |
CM-Examples: | |
Example | |
description | |
# row comment | |
| param | | |
| value | | |
# final comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cm-test": { | |
"and": [ | |
"CM-* ", | |
"CM-And " | |
], | |
"background": [ | |
"CM-Background" | |
], | |
"but": [ | |
"CM-* ", | |
"CM-But " | |
], | |
"examples": [ | |
"CM-Examples", | |
"CM-Scenarios" | |
], | |
"feature": [ | |
"CM-Feature", | |
"CM-Business Need", | |
"CM-Ability" | |
], | |
"given": [ | |
"CM-* ", | |
"CM-Given " | |
], | |
"name": "CukeModeler Test Language", | |
"native": "CMT", | |
"scenario": [ | |
"CM-Scenario" | |
], | |
"scenarioOutline": [ | |
"CM-Scenario Outline", | |
"CM-Scenario Template" | |
], | |
"then": [ | |
"CM-* ", | |
"CM-Then " | |
], | |
"when": [ | |
"CM-* ", | |
"CM-When " | |
] | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment