ecukes/ecukes — pull request #132 by atykhonov (2014-01-29 23:20:58+00:00)
Title: Concise step definitions

While I was writing integration tests (using ecukes package) I was thinking how it could be possible to get rid regexps from step definitions.

For example there is such step definion:

```
(When "^I translate \"\\(.+\\)\" from \"\\(.+\\)\" to \"\\(.+\\)\"$"
```

My wish was to make it:
- more readable;
- avoid repetitive regexp-pattern such as ```\"\\(.+\\)\"```;
- reduce amount of attention to keep definitions to be correct;

This feature request is a try to implement these desired things. It is rather about proof of concept than about final version.

This feature request contains the functionality by means of which it is possible to define steps in the following way:

```
(When "^I translate TEXT from SOURCE-LANGUAGE to TARGET-LANGUAGE$"
```

The package treats such definition as usual: ```^I translate \"\\(.+\\)\" from \"\\(.+\\)\" to \"\\(.+\\)\"$```

The possibility to define a step definition in the usual way still remain:

```
(When "^I translate \"\\(.+\\)\" from \"\\(.+\\)\" to \"\\(.+\\)\"$"
```

There are special keywords are defined to be replaced by appropriate regexps. For example ``` CONTENTS``` will be replaced by the ```\\(?: \"\\(.*\\)\"\\|:\\)``` regexp, ```POSITION``` (```POS``` or ```NUMBER``` or ```NUM```) by ```\\([0-9]+\\)``` and ```MODE``` (```VARIABLE``` or ```VALUE```) by the ```\\(.+\\)``` pattern. Capitalized words which contains in itself any mentioned keyword and separated by "-" will be also replaced by the appropriate regexp. For example ```LINE-NUM``` or ```POINT-POSITION``` will be replaced by ```\\([0-9]+\\)```. The idea about capitalized words (separated by "-") was to make a correct decision (while replacing a keyword) by means of special endings (such as ```NUM```, ```POSITION``` etc).

In case of undefined keyword is used in step definition they replaces by default ```\"\\(.+\\)\"``` regexp pattern which matches any string. As for example, mentioned ```SOURCE-LANGUAGE``` replaces by ```\"\\(.+\\)\"```.

What do you think?