Skip to content

Commit

Permalink
Correct GIFs [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
tyranron committed Sep 17, 2021
1 parent 032f68a commit fb6a3cb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ name = "readme"
harness = false # allows Cucumber to print output instead of libtest
```

[![asciicast](https://asciinema.org/a/YP24WIM1PGr2I9znFYKfmbkyo.svg)](https://asciinema.org/a/YP24WIM1PGr2I9znFYKfmbkyo)
<script id="asciicast-YP24WIM1PGr2I9znFYKfmbkyo" src="https://asciinema.org/a/YP24WIM1PGr2I9znFYKfmbkyo.js" async data-autoplay="true" data-rows="18"></script>

For more examples check out the Book ([current][1] | [edge][2]).

Expand Down
12 changes: 6 additions & 6 deletions book/src/Getting_Started.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ fn main() {

If you run this, you should see an output like:

[![Cucumber run with just the Given step](https://asciinema.org/a/t8ezu3cajA0fBkssIy04LM9pa.svg)](https://asciinema.org/a/t8ezu3cajA0fBkssIy04LM9pa)
<script id="asciicast-t8ezu3cajA0fBkssIy04LM9pa" src="https://asciinema.org/a/t8ezu3cajA0fBkssIy04LM9pa.js" async data-autoplay="true" data-rows="24"></script>

You will see a checkmark next to `Given A hungry cat`, which means that test step has been matched and executed.

Expand Down Expand Up @@ -200,7 +200,7 @@ fn feed_cat(world: &mut AnimalWorld) {

If you run the tests again, you'll see that two lines are green now and the next one is marked as not yet implemented:

[![Cucumber run with a Given and When step](https://asciinema.org/a/aWGpouW2F8lQRQ1O2eUQTRSlE.svg)](https://asciinema.org/a/aWGpouW2F8lQRQ1O2eUQTRSlE)
<script id="asciicast-aWGpouW2F8lQRQ1O2eUQTRSlE" src="https://asciinema.org/a/aWGpouW2F8lQRQ1O2eUQTRSlE.js" async data-autoplay="true" data-rows="16"></script>

Finally: how do we validate our result? We expect that this will cause some change in the cat and that the cat will no longer be hungry since it has been fed. The `then()` step follows to assert this, as our feature says:
```rust
Expand Down Expand Up @@ -260,7 +260,7 @@ fn cat_is_fed(world: &mut AnimalWorld) {

If you run the test now, you'll see that all steps are accounted for and the test succeeds:

[![Full Cucumber run](https://asciinema.org/a/HaEZXiqUn0U1T8c5TaiMGX50i.svg)](https://asciinema.org/a/HaEZXiqUn0U1T8c5TaiMGX50i)
<script id="asciicast-HaEZXiqUn0U1T8c5TaiMGX50i" src="https://asciinema.org/a/HaEZXiqUn0U1T8c5TaiMGX50i.js" async data-autoplay="true" data-rows="16"></script>

If you want to be assured that your validation is indeed happening, you can change the assertion for the cat being hungry from `true` to `false` temporarily:
```rust,should_panic
Expand Down Expand Up @@ -318,7 +318,7 @@ fn cat_is_fed(world: &mut AnimalWorld) {

And you should see the test failing:

[![Failing step](https://asciinema.org/a/KFNrNihA5ib9G7O22jwTSw0Lg.svg)](https://asciinema.org/a/KFNrNihA5ib9G7O22jwTSw0Lg)
<script id="asciicast-KFNrNihA5ib9G7O22jwTSw0Lg" src="https://asciinema.org/a/KFNrNihA5ib9G7O22jwTSw0Lg.js" async data-autoplay="true" data-rows="24"></script>

What if we also wanted to validate that even if the cat was never hungry to begin with, it wouldn't end up hungry after it was fed? We can add another scenario that looks quite similar:
```gherkin
Expand Down Expand Up @@ -398,7 +398,7 @@ We surround regex with `^..$` to ensure the __exact__ match. This is much more u

[Cucumber] will reuse these steps:

[![Steps reused between two scenarios](https://asciinema.org/a/RAteqk9p0zkvWrslK6kiOU5lc.svg)](https://asciinema.org/a/RAteqk9p0zkvWrslK6kiOU5lc)
<script id="asciicast-RAteqk9p0zkvWrslK6kiOU5lc" src="https://asciinema.org/a/RAteqk9p0zkvWrslK6kiOU5lc.js" async data-autoplay="true" data-rows="18"></script>

A contrived example, but this demonstrates that steps can be reused as long as they are sufficiently precise in both their description and implementation. If, for example, the wording for our `Then` step was `The cat is no longer hungry`, it'd imply something about the expected initial state, when that is not the purpose of a `Then` step, but rather of the `Given` step.

Expand Down Expand Up @@ -550,7 +550,7 @@ async fn main() {
}
```

[![Async Cucumber](https://asciinema.org/a/vufDjDlrdm5TtH20WVpIGpEz6.svg)](https://asciinema.org/a/vufDjDlrdm5TtH20WVpIGpEz6)
<script id="asciicast-vufDjDlrdm5TtH20WVpIGpEz6" src="https://asciinema.org/a/vufDjDlrdm5TtH20WVpIGpEz6.js" async data-autoplay="true" data-rows="18"></script>

Hm, it looks like the executor waited only for the first `Feature` 🤔, what's going on?

Expand Down

0 comments on commit fb6a3cb

Please sign in to comment.