View Source Gherkin (gherkin v2.0.0)
See Gherkin.parse/1 for primary usage.
Summary
Functions
Given a Gherkin.Element.Feature, changes all Gherkin.Elements.ScenarioOutlines
into Gherkin.ElementScenario as a flattened list of scenarios.
Primary helper function for parsing binary or streams through Gherkin. To use
simply call this function passing in the full text of the file or a file stream.
Primary helper function for parsing file through Gherkin. To use
simply call this function passing in the relative path to file.
Changes a Gherkin.Elements.ScenarioOutline into multiple Gherkin.Elements.Scenarios
so that they may be executed in the same manner.
Functions
Given a Gherkin.Element.Feature, changes all Gherkin.Elements.ScenarioOutlines
into Gherkin.ElementScenario as a flattened list of scenarios.
Primary helper function for parsing binary or streams through Gherkin. To use
simply call this function passing in the full text of the file or a file stream.
Example:
iex> "test/fixtures/coffee.feature" |> File.read!() |> Gherkin.parse() %Gherkin.Elements.Feature{
description: "As a BarristaCoffee should not be served until paid for Coffee should not be served until the button has been pressed If there is no coffee left then money should be refunded ",
line: 1,
name: "Serve coffee",
scenarios: [
%Gherkin.Elements.Scenario{
line: 7,
name: "Buy last coffee",
steps: [
%Gherkin.Elements.Step{
keyword: "Given",
line: 8,
text: "there are 1 coffees left in the machine"
}
],
}
],}
# Also supports file streams for larger files (must read by lines, bytes not supported) iex> "test/fixtures/coffee.feature" |> File.stream!() |> Gherkin.parse() %Gherkin.Elements.Feature{
description: "As a BarristaCoffee should not be served until paid for Coffee should not be served until the button has been pressed If there is no coffee left then money should be refunded ",
line: 1,
name: "Serve coffee",
scenarios: [
%Gherkin.Elements.Scenario{
line: 7,
name: "Buy last coffee",
steps: [
%Gherkin.Elements.Step{
keyword: "Given",
line: 8,
text: "there are 1 coffees left in the machine"
}
],
}
],}
Primary helper function for parsing file through Gherkin. To use
simply call this function passing in the relative path to file.
Example:
iex> Gherkin.parse_file("test/fixtures/coffee.feature") %Gherkin.Elements.Feature{
description: "As a BarristaCoffee should not be served until paid for Coffee should not be served until the button has been pressed If there is no coffee left then money should be refunded ",
file: "test/fixtures/coffee.feature",
line: 1,
name: "Serve coffee",
scenarios: [
%Gherkin.Elements.Scenario{
line: 7,
name: "Buy last coffee",
steps: [
%Gherkin.Elements.Step{
keyword: "Given",
line: 8,
text: "there are 1 coffees left in the machine"
}
],
}
],}
Changes a Gherkin.Elements.ScenarioOutline into multiple Gherkin.Elements.Scenarios
so that they may be executed in the same manner.
Given an outline, its easy to run all scenarios:
outline = %Gherkin.Elements.ScenarioOutline{}
Gherkin.scenarios_for(outline) |> Enum.each(&run_scenario/1)