NAME¶
Test::BDD::Cucumber::StepContext - Data made available to step definitions
VERSION¶
version 0.26
DESCRIPTION¶
The coderefs in Step Definitions have a single argument passed to them, a
"Test::BDD::Cucumber::StepContext" object. This is an attribute-only
class, populated by Test::BDD::Cucumber::Executor.
When steps are run normally, "C()" is set directly before execution to
return the context; this allows you to do:
sub { return C->columns }
instead of:
sub { my $c = shift; return $c->columns; }
ATTRIBUTES¶
columns¶
If the step-specific data supplied is a table, the this attribute will contain
the column names in the order they appeared.
_data¶
Step-specific data. Will either be a text string in the case of a
""" string, or an arrayref of hashrefs if the step had an
associated table.
See the "data" method below.
stash¶
A hash of hashes, containing three keys, "feature",
"scenario" and "step". The stash allows you to persist
data across features, scenarios, or steps (although the latter is there for
completeness, rather than having any useful function).
The scenario-level stash is also available to steps by calling "S()",
making the following two lines of code equivalent:
sub { my $context = shift; my $stash = $context->stash; $stash->{'count'} = 1 }
sub { S->{'count'} = 1 }
feature¶
scenario¶
step¶
Links to the Test::BDD::Cucumber::Model::Feature,
Test::BDD::Cucumber::Model::Scenario, and Test::BDD::Cucumber::Model::Step
objects respectively.
verb¶
The lower-cased verb a Step Definition was called with.
text¶
The text of the step, minus the verb. Placeholders will have already been
multiplied out at this point.
harness¶
The Test::BDD::Cucumber::Harness harness being used by the executor.
matches¶
Any matches caught by the Step Definition's regex. These are also available as
$1, $2 etc as appropriate.
is_hook¶
The harness processing the output can decide whether to shop information for
this step which is actually an internal hook, i.e. a Before or After step
METHODS¶
background¶
Boolean for "is this step being run as part of the background
section?". Currently implemented by asking the linked Scenario object...
data¶
See the "_data" attribute above.
Calling this method will return either the """ string, or a
possibly Transform-ed set of table data.
matches¶
See the "_matches" attribute above.
Call this method will return the possibly Transform-ed matches .
Used internally to transform data and placeholders, but it can also be called
from within your Given/When/Then code.
AUTHOR¶
Peter Sergeant "pete@clueball.com"
LICENSE¶
Copyright 2011-2014, Peter Sergeant; Licensed under the same terms as Perl