jnicklas/turnip — pull request #7 by bdmac (2011-11-16 03:46:00+00:00)
Title: Exact step matchers

Added the exact step matching syntax to Turnip as discussed [here](https://github.com/jnicklas/turnip/issues/6#issuecomment-2746276).

There is a new (currently undocumented) config var to control this behavior. `Turnip::Config.step_match_mode` can be set to one of three values: :flexible, :exact, :generic. I'm not sure if these are the best names for the modes but here is how they work...

:flexible is the default. This allows you to write steps using either the existing syntax or the new exact syntax. For example steps can be either:

``` Cucumber
step 'Given I am on the homepage' do
```

or

``` Cucumber
step 'I am on the homepage' do
```

:exact will ONLY match the exact version of steps. Only `step 'Given I am on the homepage' do` will match.

:generic will ONLY match the loose version of steps. Only `step 'I am on the homepage' do` will match.

This new feature works with Gherkin's i18n support including languages with multiple variants for various keywords (e.g. Spanish Given => Dado, Dada, Dados, Dadas). In fact under the covers it uses Gherkin's i18n language class to do a lot of the heavy lifting of figuring out what "kind" of step this is.

It also handles the ambiguous And and But steps. It will backtrack up through previous steps until it finds a "primary" keyword step, either Given, When, or Then. It will then add the variants for that keyword to its own keyword. For example:

```Cucumber
Scenario:
Given something great
And something not so great
```

The And step will backtrack to the Given step. In English the And step would then match either `step 'Given something not so great'` or `step 'And something not so great'`.

New examples, including a Spanish version, have been added.