Cucumber.StepDefinition (Cucumber v1.0.0)
View SourceProvides macros for defining cucumber step definitions.
Usage
defmodule AuthenticationSteps do
use Cucumber.StepDefinition
step "I am logged in as {string}", %{args: [username]} = context do
{:ok, Map.put(context, :current_user, username)}
end
endRegular expression patterns
Steps can also be defined with a regular expression instead of a cucumber
expression. The regex must match the entire step text, and capture groups
arrive in context.args in order — always as strings (no type conversion),
with nil for unmatched optional groups:
step ~r/^I have (\d+) cukes(?: in my (.+))?$/, %{args: [count, location]} = context do
{:ok, Map.put(context, :cukes, {String.to_integer(count), location})}
end
Summary
Functions
Defines a step implementation.