WhiteBread v3.1.0 WhiteBread.Context.StepFunction

Summary

Functions

Indicates if the step function matches the given string. String step functions match if the whole string matches. Regex steps pass the call to Regex.match?

Functions

call(step_function, step, state)
match?(data, string)

Indicates if the step function matches the given string. String step functions match if the whole string matches. Regex steps pass the call to Regex.match?

Example - String step functions

iex> step_function = StepFunction.new("hello midgard", fn -> :hooray end)
iex> StepFunction.match?(step_function, "hello midgard")
true

iex> step_function = StepFunction.new("hello asgard", fn -> :hooray end)
iex> StepFunction.match?(step_function, "hello midgard")
false

Example - Regex step functions

iex> step_function = StepFunction.new(~r/^hello (.+)$/, fn -> :hooray end)
iex> StepFunction.match?(step_function, "hello midgard")
true

iex> step_function = StepFunction.new(~r/^hello ([a-z]+)$/, fn -> :hooray end)
iex> StepFunction.match?(step_function, "hello midgard 9")
false
new(regex, func)
type(step_function)