Skip to content
Discussion options

You must be logged in to vote

@jmevel we have this topic covered in the "Doc strings" chapter of the Book:

Feature: Animal feature
   
  Scenario: If we feed a hungry cat it will no longer be hungry
    Given a hungry cat
      """
      A hungry cat called Felix is rescued from a Whiskas tin in a calamitous 
      mash-up of cat food brands.
      """
    When I feed the cat
    Then the cat is not hungry

In a step matching function, there’s no need to find this text and match it with a pattern. Instead, it may be accessed via Step argument:

#[given(regex = r"^a (hungry|satiated) cat$")]
async fn hungry_cat(world: &mut AnimalWorld, step: &Step, state: String) {
    // Feed only Leo and Felix.
    if !step
        .d…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@jmevel
Comment options

Answer selected by jmevel
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
question Further information is requested k::api Related to API (application interface)
2 participants