Struct cucumber::state::Cucumber
[−]
[src]
pub struct Cucumber<World> { pub tags: Vec<String>, // some fields omitted }
The Cucumber state wrapper
This struct maintains the list of primitive step components, and does the lookups to find and execute steps. It also maintains the current tags
This struct is typically only used directly when invoking steps from other steps, as in the example. Otherwise, it is managed by the WorldRunner
Example
use cucumber::{ cucumber_regex, Cucumber }; fn main() { let mut cuke: Cucumber<u32> = Cucumber::new(); cuke.insert_step("dummy_path".to_owned(), cucumber_regex::build("^test$"), Box::new(move |c: &Cucumber<u32>, world: &mut u32, _| { // Undefined step here will return a "no match" error c.invoke("another step", world, None) })); }
Fields
Methods
impl<World> Cucumber<World>
[src]
fn new() -> Cucumber<World>
fn insert_step(&mut self, path: String, regex: Regex, step: SimpleStep<World>)
Add a new step to the set of steps.
This method is typically executed by a
WorldRunner when
#given
, #when
or #then
methods are called.
fn find_match(&self, str: &str) -> Vec<ResponseStep>
Find a step or steps matching a given string.
This method is typically executed by a WorldRunner when trying to find a step corresponding to a string provided by the Server.
fn pending(&self, message: &str)
Set a step pending with a useful message
fn fail(&self, message: &str)
Fails with a useful message
fn succeed_immediately(&self)
Ends step execution successfully. I have no idea why anyone would want to do this, but it fills out the "pending, fail, success" set.
fn invoke(&self, str: &str, world: &mut World, extra_arg: Option<InvokeArgument>)
Directly execute the step matched by a regular expression.
The most typical method applied on a Cucumber instance, this method allows steps to invoke other steps. The final argument is for use with docstring arguments or tables.
fn step(&self, id: StepId) -> Option<&SimpleStep<World>>
Retrieve a step based on its Id
This method is typically executed by a WorldRunner when a request specifically invokes a step by Id. This is typical of the Cucumber Wire protocol.