Skip to content

Commit

Permalink
📚 [README] Gherkin example
Browse files Browse the repository at this point in the history
Problem:
- There is no gherkin example in README.

Solution:
- Add a simple gherkin feature test to README.
  • Loading branch information
kris-jusiak authored and krzysztof-jusiak committed May 25, 2020
1 parent 622d7a1 commit 9590225
Showing 1 changed file with 38 additions and 1 deletion.
39 changes: 38 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ int main() {
All tests passed (2 asserts in 1 tests)
```

> https://godbolt.org/z/chvYvx
> https://godbolt.org/z/cVNkA5
> Nice, is `Spec` notation supported as well?
Expand Down Expand Up @@ -724,6 +724,43 @@ All tests passed (2 asserts in 1 tests)
</p>
</details>

<details open><summary>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Gherkin</summary>
<p>

```cpp
int main() {
bdd::gherkin::steps steps = [](auto& steps) {
steps.feature("*") = [&] {
steps.scenario("*") = [&] {
steps.given("I have a number {value}") = [&](int value) {
auto number = value;
steps.when("I add {value} to it") = [&](int value) { number += value; };
steps.then("I expect number to be {value}") = [&](int value) { expect(that % number == value); };
};
};
};
};

"Gherkin"_test = steps |
R"(
Feature: Number
Scenario: Addition
Given I have a number 40
When I add 2 to it
Then I expect number to be 42
)";
}
```

```
All tests passed (1 asserts in 1 tests)
```

> https://godbolt.org/z/BP3hyt
</p>
</details>

<details open><summary>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Spec</summary>
<p>

Expand Down

0 comments on commit 9590225

Please sign in to comment.