You can use this extension to include your gherkin feature files in asciidoc in the form of sections, paragraphs, lists and tables.
The conversion is based on a simple and customizable erb template.
Thanks to https://github.com/domgold/asciidoctor-gherkin-extension for the work.
This project is up to date with the last gherkin specification and use the last version of the https://github.com/cucumber/gherkin library. Take a look at https://cucumber.io/docs/gherkin/reference/ to see the full supported syntax.
The following feature
Feature: A simple feature This is the feature description. Background: Background Given a simple background step. Scenario: Scenario title Given a simple scenario step When I render the asciidoctor content to html Then my feature gets nicely formatted in html.
can be included via the gherkin block macro :
gherkin::./simple.feature[]
and gets rendered into a 3rd level section with subsections :
=== A simple feature This is the feature description. ==== Background * *Given* a simple background step. ==== Scenario title * *Given* a simple scenario step * *When* I render the asciidoctor content to html * *Then* my feature gets nicely formatted in html.
If the 3rd level section doesn’t match the section level at the point where you want to include your feature file, you can adjust the section level via the :leveloffset:
attribute.
:leveloffset: -1 gherkin::./simple.feature[] :leveloffset: +1
Or just create your own template.
You can use the template
attribute to specify a custom erb
template.
The attribute value is used as a relative file path, resolved using the docdir attribute as base directory.
The template receives a hash called feature
containing the feature elements (scenarios, steps, examples, docstrings etc.).
Here is an example of a custom template rendering a table with one row per scenario :
:tip-caption: 💡 :tip-caption: :bulb: [TIP] ==== Implemented feature: https://linkToMyFeature[<%= feature.getName() %>] ====
assuming you place this template in the same directory as your asciidoc file, the following asciidoc content
gherkin::./simple.feature[template=mytemplate.erb]
would render like
💡
|
Implemented feature: My feature title |