macros4cuke 0.4.07 → 0.4.08
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/CHANGELOG.md +6 -0
- data/README.md +15 -4
- data/features/1_Basics/README.md +78 -0
- data/features/{demo01.feature → 1_Basics/demo01.feature} +5 -3
- data/features/2_Macros_with_arguments/README.md +47 -0
- data/features/2_Macros_with_arguments/demo02.feature +51 -0
- data/features/2_Macros_with_arguments/demo03.feature +35 -0
- data/features/3_Macros_with_table_arguments/README.md +88 -0
- data/features/{demo04.feature → 3_Macros_with_table_arguments/demo04.feature} +5 -4
- data/features/{demo05.feature → 3_Macros_with_table_arguments/demo05.feature} +8 -7
- data/features/{demo06.feature → 4_Conditional_steps/demo06.feature} +0 -0
- data/features/5_Goodies/demo07.feature +29 -0
- data/features/{demo07.feature → 5_Goodies/demo08.feature} +1 -1
- data/features/README.md +20 -0
- data/lib/macros4cuke/constants.rb +1 -1
- metadata +15 -10
- data/features/demo02.feature +0 -34
- data/features/demo03.feature +0 -53
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MjExN2JjMDk1OTE2MDAyODlmNzFlYjU5MjBhNzBjM2U3MTYwNjA1MA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
M2NhYzE4ZjkxOGExNGZkODNjYTI0YWEyYTA0MzJiY2I4MzkwNzdjOA==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MDliNGIyNDBmZjhlOGNjMjg2ZjRhNGRiZWY0NjM2ZTc2N2IzMzUxNTg1Mzgz
|
10
|
+
NGE3OTVkMTM3YzMyMTc1MTQwODk3YjhjMzdhOWQzMmNjNDE5MjE1MjIzOGEx
|
11
|
+
NmY0NjIwM2ExMzBkOTBmNDg1YWMyYTU3YmM1ZWNjOGYwNDYxMjQ=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
M2QwZjk4ZTA2YTEyYWQxYjNhN2RlNDBkY2M5ZmI0MTM3ODA1YTFkMDQ1MDZl
|
14
|
+
M2UxNTllM2E1MWUyNTBlYjhhMjg0MzFiNDQ1NTExYmQ2N2NhZjdmZTc1MGFj
|
15
|
+
YmNhNzQyMzYyMDMwZTE2Y2Y5ZWQwNmE0ZjJiMThmMzUyMjk4MGI=
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
### 0.4.08 / 2014-02-08
|
2
|
+
* [NEW] Added some tutorial material in [Relish] (https://www.relishapp.com/famished-tiger/macros4cuke/docs)
|
3
|
+
* [CHANGE] `features` dir and feature files re-designed for publishing on Relish website.
|
4
|
+
* [CHANGE] File `macros4cuke.gemspec`: RDOC is configured to use UTF-8 charset
|
5
|
+
* [CHANGE] File `README.md`: Updated with links to Relish website.
|
6
|
+
|
1
7
|
### 0.4.07 / 2014-02-04
|
2
8
|
* [FIX] Addressed Rubocop 0.18 complains string concatenation over multiple lines.
|
3
9
|
* [CHANGE] File `formatting-service_spec.rb`: Replaced string operators + by newline escapes
|
data/README.md
CHANGED
@@ -7,11 +7,12 @@ Macros4Cuke
|
|
7
7
|
|
8
8
|
_Add macros to your Cucumber scenarios._
|
9
9
|
[Homepage](https://github.com/famished-tiger/Macros4Cuke)
|
10
|
+
[Documentation] (https://www.relishapp.com/famished-tiger/macros4cuke/docs)
|
10
11
|
|
11
|
-
__Macros4Cuke__ is a
|
12
|
-
With it, you can create any new step that replaces a sequence of
|
12
|
+
__Macros4Cuke__ is a Cucumber extension that adds a macro facility for your Cucumber scenarios.
|
13
|
+
With it, you can create any new step that replaces a sequence of sub-steps.
|
13
14
|
All this can be done directly in your feature files without programming step definitions.
|
14
|
-
|
15
|
+
|
15
16
|
### Highlights ###
|
16
17
|
* Works with out-of-the-box Cucumber
|
17
18
|
* Simple installation and setup (no programming required),
|
@@ -22,6 +23,7 @@ __Macros4Cuke__ is a lightweight library that adds a macro facility your Cucumbe
|
|
22
23
|
* Domain neutral: applicable to any kind of application that can be driven with Cucumber,
|
23
24
|
* A group of sub-steps can be made conditional.
|
24
25
|
|
26
|
+
|
25
27
|
Since version 0.4.00, it is also possible to [list all the encountered macro definitions](#listing-all-the-macro-definitions).
|
26
28
|
|
27
29
|
## A quick example ##
|
@@ -437,6 +439,15 @@ text in an entry field may be noticeably different than skipping that same entry
|
|
437
439
|
Think of specific UI-events that can trigger some special system response.
|
438
440
|
|
439
441
|
|
442
|
+
## More documentation ##
|
443
|
+
More samples and documentation can be found in the `features` folder. It contains
|
444
|
+
many feature files and README.md -in Markdown format-.
|
445
|
+
Most of the material has been rewritten and adapted so that it can be consulted at the Relish website.
|
446
|
+
Relish -The living document- website is great to turn your feature files into an attractive documentation.
|
447
|
+
|
448
|
+
[Macros4Cuke @ Relish] (https://www.relishapp.com/famished-tiger/macros4cuke/docs)
|
449
|
+
|
450
|
+
|
440
451
|
## Listing all the macro definitions ##
|
441
452
|
When one begins to write macros spread over a large collection of feature files
|
442
453
|
it becomes interesting to have an overview, a list of all macro ever defined.
|
@@ -526,4 +537,4 @@ Macros with Cucumber is a hot topic, so it is good to know what other people say
|
|
526
537
|
|
527
538
|
Copyright
|
528
539
|
---------
|
529
|
-
Copyright (c)
|
540
|
+
Copyright (c) 2014, Dimitri Geshef. Macros4Cuke is released under the MIT License see [LICENSE.txt](https://github.com/famished-tiger/Macros4Cuke/blob/master/LICENSE.txt) for details.
|
@@ -0,0 +1,78 @@
|
|
1
|
+
# A first example #
|
2
|
+
Let's assume that our friend Joe wants to test a basic calculator.
|
3
|
+
Joe uses Cucumber with a generic library of user interface steps that
|
4
|
+
allows him to perform user actions like:
|
5
|
+
- Filling a text field,
|
6
|
+
- Pressing on a button,
|
7
|
+
- Clicking on a link,...
|
8
|
+
|
9
|
+
|
10
|
+
For instance, the Cucumber steps necessary to calculate the sum of 8 + 3 are:
|
11
|
+
```cucumber
|
12
|
+
When I type 8
|
13
|
+
And I click Enter
|
14
|
+
And I type 3
|
15
|
+
And I click Enter
|
16
|
+
And I click Add
|
17
|
+
Then I should see 11
|
18
|
+
```
|
19
|
+
|
20
|
+
|
21
|
+
What strikes Joe is that some step sequences are repeating again and again in
|
22
|
+
many of his scenarios. As an example Joe would like to replace the scenario fragment:
|
23
|
+
```cucumber
|
24
|
+
When I type 8
|
25
|
+
And I click Enter
|
26
|
+
```
|
27
|
+
|
28
|
+
by something shorter like:
|
29
|
+
```cucumber
|
30
|
+
When I enter the number 8
|
31
|
+
```
|
32
|
+
|
33
|
+
For a programmer familiar with Cucumber, Joe's wish is a piece of a cake to achieve.
|
34
|
+
Alas, while Joe is a terrific tester he has little programming experience. Accordingly,
|
35
|
+
he doesn't feel confident enough to program step definitions. Or maybe he isn't knowledgeable
|
36
|
+
in the API used by the calculator...
|
37
|
+
|
38
|
+
Luckily, Joe is rescued from despair and when he reads in the next paragraph how
|
39
|
+
to get rid of the infamous scenario fragment.
|
40
|
+
|
41
|
+
|
42
|
+
With __Macros4Cuke__, all Joe has to do to create his wished new macro-step is:
|
43
|
+
|
44
|
+
```cucumber
|
45
|
+
...
|
46
|
+
Given I define the step "When I [enter the number <value>]" to mean:
|
47
|
+
"""
|
48
|
+
When I type <value>
|
49
|
+
And I click Enter
|
50
|
+
"""
|
51
|
+
...
|
52
|
+
```
|
53
|
+
|
54
|
+
Once this is done, then the original scenario above can be rewritten as follows:
|
55
|
+
```cucumber
|
56
|
+
When I [enter the number "8"]
|
57
|
+
And I [enter the number "3"]
|
58
|
+
And I click Add
|
59
|
+
Then I should see 11
|
60
|
+
```
|
61
|
+
|
62
|
+
No programming was required! The only price to pay are the step syntax conventions imposed by __Macros4Cuke__ (e.g. the square brackets and the quotes).
|
63
|
+
But this is really bargain compared to the added convenience.
|
64
|
+
|
65
|
+
With a little imagination, Joe could even reduce the last scenario to something like:
|
66
|
+
```cucumber
|
67
|
+
When I [calculate the sum of "8" and "3"]
|
68
|
+
Then I should see 11
|
69
|
+
```
|
70
|
+
|
71
|
+
See how the last example looks more natural and readable for a genuine calculator user.
|
72
|
+
|
73
|
+
Are you interested to reduce the length of your scenarios or do you want to use higher-level
|
74
|
+
steps that conceal the boring details without fiddling with step definition programming?...
|
75
|
+
|
76
|
+
Then give __Macros4Cuke__ a try...
|
77
|
+
|
78
|
+
|
@@ -1,16 +1,18 @@
|
|
1
1
|
# File: demo01.feature
|
2
2
|
|
3
|
-
Feature:
|
3
|
+
Feature: Define and use a basic macro-step
|
4
4
|
As a Cuke user
|
5
|
-
|
5
|
+
I want to create macro-steps that replace repeating lower-level steps
|
6
|
+
So that I can write shorter and more readable scenarios.
|
6
7
|
|
7
8
|
|
8
|
-
Scenario:
|
9
|
+
Scenario: Defining a simple macro-step
|
9
10
|
# The next step creates a macro(-step)
|
10
11
|
# The syntax of the new macro-step is specified between double quotes.
|
11
12
|
# The steps to execute when the macro is used/invoked are listed in the multiline triple quotes arguments.
|
12
13
|
Given I define the step "* I [log in]" to mean:
|
13
14
|
"""
|
15
|
+
# Here follows the steps to execute when this macro is called
|
14
16
|
Given I landed in the homepage
|
15
17
|
When I click "Sign in"
|
16
18
|
And I fill in "Username" with "johndoe"
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# Passing data values to a macro-step #
|
2
|
+
|
3
|
+
Macro-steps as defined in the _Basics_ section are pretty limited.
|
4
|
+
|
5
|
+
Remember Joe and his calculator?...
|
6
|
+
Suppose that Joe created a macro-step as follows:
|
7
|
+
```cucumber
|
8
|
+
...
|
9
|
+
Given I define the step "When I [enter the number 8]" to mean:
|
10
|
+
"""
|
11
|
+
When I type 8
|
12
|
+
And I click Enter
|
13
|
+
"""
|
14
|
+
...
|
15
|
+
```
|
16
|
+
|
17
|
+
While being a perfectly valid macro, it is almost useless since it will always enter the same digit 8.
|
18
|
+
|
19
|
+
What Joe really needs is a macro-step that allows him to enter any number.
|
20
|
+
His wish, in turn, implies that the previous macro-step should accept one parameter value: the number to enter.
|
21
|
+
|
22
|
+
Here is how Joe might proceed:
|
23
|
+
```cucumber
|
24
|
+
...
|
25
|
+
Given I define the step "When I [enter the number <some_number>]" to mean:
|
26
|
+
"""
|
27
|
+
When I type <some_number>
|
28
|
+
And I click Enter
|
29
|
+
"""
|
30
|
+
...
|
31
|
+
```
|
32
|
+
|
33
|
+
And here is how he can use the last macro to enter the value 2:
|
34
|
+
|
35
|
+
```cucumber
|
36
|
+
...
|
37
|
+
When I [enter the number "2"]
|
38
|
+
...
|
39
|
+
```
|
40
|
+
|
41
|
+
## Rules of the game ##
|
42
|
+
When a macro-step is required to take one or more values, then:
|
43
|
+
|
44
|
+
1. Place in the step being defined the name of an argument between chevrons < ... >.
|
45
|
+
2. When the macro is used in a scenario, place the value of the corresponding argument between double quotes "...".
|
46
|
+
|
47
|
+
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# File: demo02.feature
|
2
|
+
|
3
|
+
Feature: Define and use a macro taking one argument
|
4
|
+
As a Cuke user
|
5
|
+
I want to pass data to macro-steps
|
6
|
+
So that I can use them in more varied situations.
|
7
|
+
|
8
|
+
|
9
|
+
|
10
|
+
Scenario: Defining a macro-step with one argument (userid)
|
11
|
+
# The next step creates a macro(-step)
|
12
|
+
# The syntax of the new macro-step to create is specified between the double quotes.
|
13
|
+
# The steps to execute when the macro is used/invoked are listed in the multiline triple quotes arguments.
|
14
|
+
# The macro argument is put between chevrons <...>.
|
15
|
+
Given I define the step "* I [log in as <userid>]" to mean:
|
16
|
+
"""
|
17
|
+
Given I landed in the homepage
|
18
|
+
When I click "Sign in"
|
19
|
+
# The next step uses the macro-step argument <userid>
|
20
|
+
And I fill in "Username" with "<userid>"
|
21
|
+
And I fill in "Password" with "unguessable"
|
22
|
+
And I click "Submit"
|
23
|
+
"""
|
24
|
+
|
25
|
+
Scenario: Use the macro created above pass it a user id
|
26
|
+
# Here the macro is invoked. Actual value for the argument is put between double quotes.
|
27
|
+
When I [log in as "guest"]
|
28
|
+
|
29
|
+
# The next step verifies that the steps from the macro were effectively executed.
|
30
|
+
Then I expect the following step trace:
|
31
|
+
"""
|
32
|
+
Invoked step: ... I landed in the homepage
|
33
|
+
Invoked step: ... I click "Sign in"
|
34
|
+
Invoked step: ... I fill in "Username" with "guest"
|
35
|
+
Invoked step: ... I fill in "Password" with "unguessable"
|
36
|
+
Invoked step: ... I click "Submit"
|
37
|
+
"""
|
38
|
+
|
39
|
+
|
40
|
+
Scenario: Use the macro with another user id
|
41
|
+
When I [log in as "me-again"]
|
42
|
+
|
43
|
+
# The next step verifies that the steps from the macro were effectively executed.
|
44
|
+
Then I expect the following step trace:
|
45
|
+
"""
|
46
|
+
Invoked step: ... I landed in the homepage
|
47
|
+
Invoked step: ... I click "Sign in"
|
48
|
+
Invoked step: ... I fill in "Username" with "me-again"
|
49
|
+
Invoked step: ... I fill in "Password" with "unguessable"
|
50
|
+
Invoked step: ... I click "Submit"
|
51
|
+
"""
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# File: demo03.feature
|
2
|
+
|
3
|
+
Feature: Define and use a macro taking several arguments
|
4
|
+
As a Cuke user
|
5
|
+
I want versatile macro-steps that accept more than one data argument
|
6
|
+
So that I can use them in varied situations.
|
7
|
+
|
8
|
+
|
9
|
+
Scenario: Defining a macro with multiple arguments
|
10
|
+
# The next step creates a macro(-step)double quotes.
|
11
|
+
# The steps to execute when the macro is used/invoked are listed in the multiline triple quotes arguments.
|
12
|
+
# The macro-step arguments are put between chevrons <...>.
|
13
|
+
Given I define the step "* I [enter my userid <userid> and password <password>]" to mean:
|
14
|
+
"""
|
15
|
+
Given I landed in the homepage
|
16
|
+
When I click "Sign in"
|
17
|
+
And I fill in "Username" with "<userid>"
|
18
|
+
And I fill in "Password" with "<password>"
|
19
|
+
And I click "Submit"
|
20
|
+
"""
|
21
|
+
|
22
|
+
Scenario: Using the macro with multiple arguments
|
23
|
+
# Here the macro is invoked. Actual value for the argument is put between double quotes.
|
24
|
+
When I [enter my userid "jdoe" and password "cosmic"]
|
25
|
+
|
26
|
+
# The next step verifies that the steps from the macro were effectively executed.
|
27
|
+
Then I expect the following step trace:
|
28
|
+
"""
|
29
|
+
Invoked step: ... I landed in the homepage
|
30
|
+
Invoked step: ... I click "Sign in"
|
31
|
+
Invoked step: ... I fill in "Username" with "jdoe"
|
32
|
+
Invoked step: ... I fill in "Password" with "cosmic"
|
33
|
+
Invoked step: ... I click "Submit"
|
34
|
+
"""
|
35
|
+
|
@@ -0,0 +1,88 @@
|
|
1
|
+
# Passing values to a macro-step through a table #
|
2
|
+
|
3
|
+
## Learned so far ##
|
4
|
+
|
5
|
+
We discovered in the previous sections how to:
|
6
|
+
- Create a macro-step, and
|
7
|
+
- Pass data values to it.
|
8
|
+
|
9
|
+
As a further, example, here is the of a macro-step that takes three arguments such as:
|
10
|
+
```cucumber
|
11
|
+
Given I define the step "When I [fly from <origin> to <destination> via <stopover>]" to mean:
|
12
|
+
"""
|
13
|
+
When I take-off from <origin>
|
14
|
+
And I land in <stopover>
|
15
|
+
And I take-off from <stopover>
|
16
|
+
And I land in <destination>
|
17
|
+
"""
|
18
|
+
```
|
19
|
+
|
20
|
+
Our macro-step can be used in a scenario like this:
|
21
|
+
|
22
|
+
```cucumber
|
23
|
+
...
|
24
|
+
When I [fly from "Copenhagen" to "Milan" via "Paris"]
|
25
|
+
...
|
26
|
+
```
|
27
|
+
|
28
|
+
The text between double quotes, such as "Milan" are data values that the macro
|
29
|
+
will use when it executes its own sub-steps.
|
30
|
+
|
31
|
+
## Using a table to pass data to a macro-step ##
|
32
|
+
|
33
|
+
While the use of macro-steps parameters is rather straightforward, it is however not always
|
34
|
+
very practical in situations when:
|
35
|
+
- A lot of arguments (say, more than 4) must be passed; or,
|
36
|
+
- Some arguments take long text values.
|
37
|
+
|
38
|
+
In these cases, with the approach described above we end up with steps that are
|
39
|
+
very long and hard to follow.
|
40
|
+
|
41
|
+
Therefore, __Macros4Cuke__ provides an alternative step syntax that allows you to pass
|
42
|
+
data values through a table.
|
43
|
+
|
44
|
+
The syntax for the macro definition is almost the same as above
|
45
|
+
|
46
|
+
```cucumber
|
47
|
+
Given I define the step "When I [fly to <destination>]:" to mean:
|
48
|
+
"""
|
49
|
+
When I take-off from <from>
|
50
|
+
And I land in <via>
|
51
|
+
And I take-off from <via>
|
52
|
+
And I land in <destination>
|
53
|
+
"""
|
54
|
+
```
|
55
|
+
|
56
|
+
Did you spot the key difference? There is a colon ':' character right after the closing bracket ']'.
|
57
|
+
It is this colon character that tells __Macros4Cuke__ that some arguments will be passed via a table.
|
58
|
+
Also some argument names were changed in order to make the syntax of a call to the macro-step more natural.
|
59
|
+
|
60
|
+
The syntax to call the macro with a table of arguments is as follows:
|
61
|
+
```cucumber
|
62
|
+
When I [fly to "Milan"]:
|
63
|
+
|from |Copenhague|
|
64
|
+
|via |Paris |
|
65
|
+
```
|
66
|
+
|
67
|
+
There are three argument values. The first one "Milan" is passed directly in the step sentence.
|
68
|
+
The two others are passed via a table.
|
69
|
+
|
70
|
+
## Rules of the game ##
|
71
|
+
Here are the conventions to apply when a macro-step is required to take values via a table.
|
72
|
+
In the macro definition:
|
73
|
+
1. Add a colon ':' just after the closing square bracket.
|
74
|
+
2. You are allowed to pass also arguments in the step sentence.
|
75
|
+
|
76
|
+
When calling the macro:
|
77
|
+
3. The table used to pass arguments must have exactly two columns.
|
78
|
+
4. The first column contains the argument names.
|
79
|
+
5. The second column contains the argument values.
|
80
|
+
6. A row consists of a pair argument name - its value
|
81
|
+
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
|
88
|
+
|
@@ -1,8 +1,9 @@
|
|
1
1
|
# File: demo04.feature
|
2
2
|
|
3
|
-
Feature:
|
3
|
+
Feature: Define and use a macro with arguments in a table
|
4
4
|
As a Cuke user
|
5
|
-
|
5
|
+
I want to pass many arguments to a macro-step
|
6
|
+
So that I can use flexible and readable macros.
|
6
7
|
|
7
8
|
|
8
9
|
Scenario: Defining a macro to be used with multiple arguments in a table
|
@@ -19,10 +20,10 @@ Scenario: Defining a macro to be used with multiple arguments in a table
|
|
19
20
|
And I click "Submit"
|
20
21
|
"""
|
21
22
|
|
22
|
-
Scenario:
|
23
|
+
Scenario: Using the macro we created above
|
23
24
|
# Here the macro is invoked. Actual value for the argument are passed in a table argument.
|
24
25
|
When I [enter my credentials as]:
|
25
|
-
|userid|guest|
|
26
|
+
|userid |guest |
|
26
27
|
|password|unguessable|
|
27
28
|
|
28
29
|
# The next step verifies that the steps from the macro were effectively executed.
|
@@ -1,8 +1,9 @@
|
|
1
1
|
# File: demo05.feature
|
2
2
|
|
3
|
-
Feature:
|
3
|
+
Feature: Yet another example of: passing a Cucumber table into a macro-step
|
4
4
|
As a Cuke user
|
5
|
-
|
5
|
+
I want to pass many arguments to a macro-step
|
6
|
+
So that I can use flexible and readable macros.
|
6
7
|
|
7
8
|
|
8
9
|
Scenario: Defining a macro to be used with multiple arguments in a table
|
@@ -18,14 +19,14 @@ Scenario: Defining a macro to be used with multiple arguments in a table
|
|
18
19
|
And I click "Save"
|
19
20
|
"""
|
20
21
|
|
21
|
-
Scenario:
|
22
|
+
Scenario: Using the macro we created above
|
22
23
|
# Here the macro is invoked. Actual value for the argument are passed in a table argument.
|
23
24
|
When I [enter my profile as]:
|
24
25
|
|location|Nowhere-City|
|
25
|
-
|email|nobody@example.com|
|
26
|
-
|comment|First comment line|
|
27
|
-
|comment|Second comment line|
|
28
|
-
|comment|Third comment line|
|
26
|
+
|email |nobody@example.com |
|
27
|
+
|comment |First comment line |
|
28
|
+
|comment |Second comment line|
|
29
|
+
|comment |Third comment line |
|
29
30
|
|
30
31
|
# The next step verifies that the steps from the macro were effectively executed.
|
31
32
|
Then I expect the following step trace:
|
File without changes
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# File: demo07.feature
|
2
|
+
|
3
|
+
Feature: Insert a call to existing macro-step inside a new macro
|
4
|
+
As a Cuke user
|
5
|
+
I want to be able to use a macro-step inside higher-level macro-steps
|
6
|
+
So that I can use a macro-step to execute complex step sequences
|
7
|
+
|
8
|
+
|
9
|
+
Scenario: Create a macro that uses another, existing, macro (YES, it's possible!)
|
10
|
+
Given I define the step "* I [enter my credentials]" to mean:
|
11
|
+
"""
|
12
|
+
# The next step invokes a macro-step defined elsewhere
|
13
|
+
When I [enter my userid "guest" and password "unguessable"]
|
14
|
+
"""
|
15
|
+
|
16
|
+
Scenario: Invoking the coarse-grained macro
|
17
|
+
|
18
|
+
# Invoking our lastly-created macro
|
19
|
+
When I [enter my credentials]
|
20
|
+
|
21
|
+
# Check that the nested macro still works
|
22
|
+
Then I expect the following step trace:
|
23
|
+
"""
|
24
|
+
Invoked step: ... I landed in the homepage
|
25
|
+
Invoked step: ... I click "Sign in"
|
26
|
+
Invoked step: ... I fill in "Username" with "guest"
|
27
|
+
Invoked step: ... I fill in "Password" with "unguessable"
|
28
|
+
Invoked step: ... I click "Submit"
|
29
|
+
"""
|
data/features/README.md
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
__Macros4Cuke__ is a Cucumber extension that allows you create and use new Cucumber steps without programming.
|
2
|
+
|
3
|
+
With it, your scenarios will:
|
4
|
+
- become shorter since a macro-step can replace a bunch of sub-steps,
|
5
|
+
- be more expressive by hiding low-level and boring details inside higher-level macro-steps,
|
6
|
+
- be more flexible thanks to conditional steps you can put in a macro-step.
|
7
|
+
|
8
|
+
|
9
|
+
## The project
|
10
|
+
|
11
|
+
[Get the gem](https://rubygems.org/gems/macros4cuke)
|
12
|
+
[Source on GitHub](https://github.com/famished-tiger/Macros4Cuke)
|
13
|
+
|
14
|
+
## Issues
|
15
|
+
|
16
|
+
This documentation is work in progress. If you find it incomplete or confusing,
|
17
|
+
please [submit an issue](https://github.com/famished-tiger/Macros4Cuke/issues).
|
18
|
+
|
19
|
+
|
20
|
+
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: macros4cuke
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.08
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dimitri Geshef
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-02-
|
11
|
+
date: 2014-02-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cucumber
|
@@ -131,13 +131,18 @@ files:
|
|
131
131
|
- examples/i18n/fr/features/step_definitions/demo_steps.rb
|
132
132
|
- examples/i18n/fr/features/step_definitions/use_macro_steps.rb
|
133
133
|
- examples/i18n/fr/features/support/macro_support.rb
|
134
|
-
- features/demo01.feature
|
135
|
-
- features/demo02.feature
|
136
|
-
- features/demo03.feature
|
137
|
-
- features/demo04.feature
|
138
|
-
- features/demo05.feature
|
139
|
-
- features/demo06.feature
|
140
|
-
- features/demo07.feature
|
134
|
+
- features/1_Basics/demo01.feature
|
135
|
+
- features/2_Macros_with_arguments/demo02.feature
|
136
|
+
- features/2_Macros_with_arguments/demo03.feature
|
137
|
+
- features/3_Macros_with_table_arguments/demo04.feature
|
138
|
+
- features/3_Macros_with_table_arguments/demo05.feature
|
139
|
+
- features/4_Conditional_steps/demo06.feature
|
140
|
+
- features/5_Goodies/demo07.feature
|
141
|
+
- features/5_Goodies/demo08.feature
|
142
|
+
- features/1_Basics/README.md
|
143
|
+
- features/2_Macros_with_arguments/README.md
|
144
|
+
- features/3_Macros_with_table_arguments/README.md
|
145
|
+
- features/README.md
|
141
146
|
- features/step_definitions/demo_steps.rb
|
142
147
|
- features/step_definitions/use_macro_steps.rb
|
143
148
|
- features/support/env.rb
|
@@ -169,7 +174,7 @@ post_install_message: ! '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
169
174
|
|
170
175
|
'
|
171
176
|
rdoc_options:
|
172
|
-
- --exclude="examples|features|spec"
|
177
|
+
- --charset=UTF-8 --exclude="examples|features|spec"
|
173
178
|
require_paths:
|
174
179
|
- lib
|
175
180
|
required_ruby_version: !ruby/object:Gem::Requirement
|
data/features/demo02.feature
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
# File: demo02.feature
|
2
|
-
|
3
|
-
Feature: Show the use of a basic macro with one argument
|
4
|
-
As a Cuke user
|
5
|
-
So that I enjoy writing scenario.
|
6
|
-
|
7
|
-
|
8
|
-
Scenario: Creating a basic scenario with one argument
|
9
|
-
# The next step creates a macro(-step)
|
10
|
-
# The syntax of the new macro-step is specified between the double quotes.
|
11
|
-
# The steps to execute when the macro is used/invoked are listed in the multiline triple quotes arguments.
|
12
|
-
# The macro argument is put between chevrons <...>.
|
13
|
-
Given I define the step "* I [log in\[\] as <userid>]" to mean:
|
14
|
-
"""
|
15
|
-
Given I landed in the homepage
|
16
|
-
When I click "Sign in"
|
17
|
-
And I fill in "Username" with "<userid>"
|
18
|
-
And I fill in "Password" with "unguessable"
|
19
|
-
And I click "Submit"
|
20
|
-
"""
|
21
|
-
|
22
|
-
Scenario: Let's use the macro we created above
|
23
|
-
# Here the macro is invoked. Actual value for the argument is put between double quotes.
|
24
|
-
When I [log in\[\] as "guest"]
|
25
|
-
|
26
|
-
# The next step verifies that the steps from the macro were effectively executed.
|
27
|
-
Then I expect the following step trace:
|
28
|
-
"""
|
29
|
-
Invoked step: ... I landed in the homepage
|
30
|
-
Invoked step: ... I click "Sign in"
|
31
|
-
Invoked step: ... I fill in "Username" with "guest"
|
32
|
-
Invoked step: ... I fill in "Password" with "unguessable"
|
33
|
-
Invoked step: ... I click "Submit"
|
34
|
-
"""
|
data/features/demo03.feature
DELETED
@@ -1,53 +0,0 @@
|
|
1
|
-
# File: demo03.feature
|
2
|
-
|
3
|
-
Feature: Show the use of a basic macro with multiple arguments
|
4
|
-
As a Cuke user
|
5
|
-
So that I enjoy writing scenario.
|
6
|
-
|
7
|
-
|
8
|
-
Scenario: defining basic macro with multiple arguments
|
9
|
-
# The next step creates a macro(-step)double quotes.
|
10
|
-
# The steps to execute when the macro is used/invoked are listed in the multiline triple quotes arguments.
|
11
|
-
# The macro-step arguments are put between chevrons <...>.
|
12
|
-
Given I define the step "* I [enter my userid <userid> and password <password>]" to mean:
|
13
|
-
"""
|
14
|
-
Given I landed in the homepage
|
15
|
-
When I click "Sign in"
|
16
|
-
And I fill in "Username" with "<userid>"
|
17
|
-
And I fill in "Password" with "<password>"
|
18
|
-
And I click "Submit"
|
19
|
-
"""
|
20
|
-
|
21
|
-
Scenario: Let's use the macro we created above
|
22
|
-
# Here the macro is invoked. Actual value for the argument is put between double quotes.
|
23
|
-
When I [enter my userid "guest" and password "unguessable"]
|
24
|
-
|
25
|
-
# The next step verifies that the steps from the macro were effectively executed.
|
26
|
-
Then I expect the following step trace:
|
27
|
-
"""
|
28
|
-
Invoked step: ... I landed in the homepage
|
29
|
-
Invoked step: ... I click "Sign in"
|
30
|
-
Invoked step: ... I fill in "Username" with "guest"
|
31
|
-
Invoked step: ... I fill in "Password" with "unguessable"
|
32
|
-
Invoked step: ... I click "Submit"
|
33
|
-
"""
|
34
|
-
|
35
|
-
Scenario: A macro invoking another macro (YES, it's possible!)
|
36
|
-
Given I define the step "* I [enter my credentials]" to mean:
|
37
|
-
"""
|
38
|
-
# Notice that the next step is invoking the first macro above
|
39
|
-
When I [enter my userid "guest" and password "unguessable"]
|
40
|
-
"""
|
41
|
-
|
42
|
-
# Invoking our lastly-created macro
|
43
|
-
When I [enter my credentials]
|
44
|
-
|
45
|
-
# Check that the nested macro still works
|
46
|
-
Then I expect the following step trace:
|
47
|
-
"""
|
48
|
-
Invoked step: ... I landed in the homepage
|
49
|
-
Invoked step: ... I click "Sign in"
|
50
|
-
Invoked step: ... I fill in "Username" with "guest"
|
51
|
-
Invoked step: ... I fill in "Password" with "unguessable"
|
52
|
-
Invoked step: ... I click "Submit"
|
53
|
-
"""
|