Skip to content

Commit

Permalink
This introduces the bug as well (see 2 latest commits)
Browse files Browse the repository at this point in the history
  • Loading branch information
maximetinu committed Oct 17, 2024
1 parent ceafda1 commit 139ecc2
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 16 deletions.
18 changes: 2 additions & 16 deletions crates/sub_lib_gherkin/src/sub_lib/mod.rs
Original file line number Diff line number Diff line change
@@ -1,25 +1,11 @@
use cucumber::*;
use sub_lib::Cat;

pub mod steps;

// `World` is your shared, likely mutable state.
// Cucumber constructs it via `Default::default()` for each scenario.
#[derive(Debug, Default, World)]
pub struct AnimalWorld {
pub(crate) cat: Cat,
}

// Steps are defined with `given`, `when` and `then` attributes.
#[given("a hungry cat")]
pub fn hungry_cat(world: &mut AnimalWorld) {
world.cat.hungry = true;
}

#[when("I feed the cat")]
pub fn feed_cat(world: &mut AnimalWorld) {
world.cat.feed();
}

#[then("the cat is not hungry")]
pub fn cat_is_fed(world: &mut AnimalWorld) {
assert!(!world.cat.hungry);
}
19 changes: 19 additions & 0 deletions crates/sub_lib_gherkin/src/sub_lib/steps.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
use cucumber::*;

use super::AnimalWorld;

// Steps are defined with `given`, `when` and `then` attributes.
#[given("a hungry cat")]
pub fn hungry_cat(world: &mut AnimalWorld) {
world.cat.hungry = true;
}

#[when("I feed the cat")]
pub fn feed_cat(world: &mut AnimalWorld) {
world.cat.feed();
}

#[then("the cat is not hungry")]
pub fn cat_is_fed(world: &mut AnimalWorld) {
assert!(!world.cat.hungry);
}

0 comments on commit 139ecc2

Please sign in to comment.