Cucumberex.World (cucumberex v0.2.1)

Copy Markdown View Source

World context: a plain map threaded through each scenario. Isolated per scenario — no state shared between scenarios.

Modules registered with world_module/1 have their functions imported into the world context namespace, accessible via world.module_name.fun().

Custom world factories can be registered globally.

Summary

Functions

Builds a world using the given factory, or a default empty world if nil.

Creates a fresh world for a new scenario.

Sets scenario metadata on the world.

Types

t()

@type t() :: map()

Functions

build(factory \\ nil)

Builds a world using the given factory, or a default empty world if nil.

iex> w = Cucumberex.World.build(nil)
iex> Map.has_key?(w, :__tags__)
true
iex> w = Cucumberex.World.build(fn -> %{custom: true} end)
iex> w.custom
true

new(extra \\ %{})

Creates a fresh world for a new scenario.

iex> w = Cucumberex.World.new()
iex> w.__tags__
[]
iex> w = Cucumberex.World.new(%{db: :mock})
iex> w.db
:mock

set_scenario(world, pickle)

Sets scenario metadata on the world.

iex> pickle = %{tags: [%{name: "@smoke"}], name: "Login", uri: "features/auth.feature"}
iex> w = Cucumberex.World.set_scenario(%{}, pickle)
iex> w.__tags__
["@smoke"]
iex> w.__scenario_name__
"Login"