macros4cuke 0.5.14 → 0.5.15
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +7 -9
- data/CHANGELOG.md +20 -11
- data/Gemfile +2 -2
- data/LICENSE.txt +1 -1
- data/README.md +43 -42
- data/Rakefile +54 -54
- data/appveyor.yml +20 -0
- data/bin/macros4cuke +14 -15
- data/lib/macro_steps.rb +3 -3
- data/lib/macros4cuke/application.rb +1 -3
- data/lib/macros4cuke/cli/cmd-line.rb +1 -3
- data/lib/macros4cuke/coll-walker-factory.rb +1 -1
- data/lib/macros4cuke/constants.rb +2 -2
- data/lib/macros4cuke/formatter/all-notifications.rb +1 -1
- data/lib/macros4cuke/formatter/to-gherkin.rb +4 -6
- data/lib/macros4cuke/formatter/to-null.rb +14 -14
- data/lib/macros4cuke/formatter/to-trace.rb +1 -3
- data/lib/macros4cuke/formatting-service.rb +2 -2
- data/lib/macros4cuke/macro-collection.rb +4 -6
- data/lib/macros4cuke/macro-step-support.rb +0 -2
- data/lib/macros4cuke/macro-step.rb +18 -19
- data/lib/macros4cuke/templating/comment.rb +0 -2
- data/lib/macros4cuke/templating/engine.rb +26 -29
- data/lib/macros4cuke/templating/eo-line.rb +18 -21
- data/lib/macros4cuke/templating/placeholder.rb +12 -12
- data/lib/macros4cuke/templating/section.rb +1 -5
- data/lib/macros4cuke/templating/static-text.rb +0 -2
- data/lib/macros4cuke/templating/template-element.rb +6 -7
- data/spec/macros4cuke/cli/cmd-line_spec.rb +4 -4
- data/spec/macros4cuke/coll-walker-factory_spec.rb +42 -42
- data/spec/macros4cuke/formatter/to-trace_spec.rb +148 -149
- data/spec/macros4cuke/macro-collection_spec.rb +2 -2
- data/spec/macros4cuke/macro-step-support_spec.rb +10 -9
- data/spec/macros4cuke/macro-step_spec.rb +10 -9
- data/spec/macros4cuke/templating/comment_spec.rb +37 -38
- data/spec/macros4cuke/templating/engine_spec.rb +19 -22
- data/spec/macros4cuke/templating/eo-line_spec.rb +31 -32
- data/spec/macros4cuke/templating/placeholder_spec.rb +1 -2
- data/spec/macros4cuke/templating/section_spec.rb +10 -7
- data/spec/macros4cuke/templating/static_text_spec.rb +38 -39
- data/spec/macros4cuke/use-sample-collection.rb +3 -3
- metadata +9 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1f585f9021fd1f335181c02c792d82f651012e5a
|
4
|
+
data.tar.gz: 71ecc879f73740225a10181a4068417f45c6a5da
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a8bf9ed9629fcd69f8df584bb006b24dc531144f2e1b7f345a587f3f4595f3f5f4dab9483ad4452e00d489aef92aba803da6963910e0b57e763ee6b5c98717cd
|
7
|
+
data.tar.gz: 5c3f819372840ecc854d7b4b9a150a96b00fac39d8fe51389a9795e3d42a5a45458e8dc87917b64ac8e57d9a7c7a6fc6dbcbabb6a1907396620462ae7d6cd1b2
|
data/.travis.yml
CHANGED
@@ -1,20 +1,18 @@
|
|
1
1
|
language: ruby
|
2
2
|
rvm:
|
3
3
|
- ruby-head
|
4
|
-
-
|
5
|
-
- 2.
|
6
|
-
- 2.
|
7
|
-
- 2.
|
8
|
-
-
|
9
|
-
- jruby
|
10
|
-
- jruby-19mode
|
11
|
-
|
4
|
+
- jruby-head
|
5
|
+
- 2.3.3
|
6
|
+
- 2.2.6
|
7
|
+
- 2.1.9
|
8
|
+
- 2.0.0
|
9
|
+
- jruby
|
12
10
|
|
13
11
|
# Workaround issue of jruby-head configuration on Travis CI
|
14
12
|
matrix:
|
15
13
|
allow_failures:
|
16
|
-
- rvm: jruby-head
|
17
14
|
- rvm: ruby-head
|
15
|
+
- rvm: jruby-head
|
18
16
|
|
19
17
|
gemfile:
|
20
18
|
- Gemfile
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
### 0.5.15 / 2016-12-21
|
2
|
+
* [NEW] File `appveyor.yml`: Added AppVeyor CI so that Macros4Cuke builds also
|
3
|
+
can be tested on Windows. This complements the Travis CI which runs on Linux.
|
4
|
+
* [CHANGE] File `README.md` Added AppVeyor badge
|
5
|
+
* [CHANGE] A pass to adapt code style in order to please Rubocop 0.46.0
|
6
|
+
* [CHANGE] File `.travis.yml` Added support for Ruby 2.3.x, dropped Ruby 1.9.3
|
7
|
+
* [CHANGE] File `macros4cuke.gemspec` Minimal Ruby version supported is now Ruby 2.0.0
|
8
|
+
|
9
|
+
|
1
10
|
### 0.5.14 / 2016-03-16
|
2
11
|
* [FIX] File `macro_steps`: Cucumber complained about allusion to deprecated class `Cucumber::Ast::Table`.
|
3
12
|
|
@@ -106,9 +115,9 @@
|
|
106
115
|
* [CHANGE] File `.rubocop.yml`: Disabled a few new 0.15.0 cops
|
107
116
|
* [CHANGE] Files from `lib` and `spec` dirs updated for Rubocop 0.15.0
|
108
117
|
|
109
|
-
### 0.4.00 / 2013-11-17
|
118
|
+
### 0.4.00 / 2013-11-17
|
110
119
|
#### Version number bumped. New feature: to list all encountered macro definitions into a single feature file.
|
111
|
-
* [FEATURE] Sample `demo07.feature` file illustrates the new step that will list all macro definitions.
|
120
|
+
* [FEATURE] Sample `demo07.feature` file illustrates the new step that will list all macro definitions.
|
112
121
|
* [NEW] Class CollWalkerFactory. Creates specialized Enumerators that walk over the macro collection.
|
113
122
|
* [NEW] Module Formatter. Purpose: Grouping of all classes that render macro definitions
|
114
123
|
* [NEW] File `all-notifications.rb` List of macro collection visit events.
|
@@ -145,16 +154,16 @@
|
|
145
154
|
### 0.3.37 / 2013-06-27
|
146
155
|
* [FIX] File `macros4cuke.gemspec`: added README.md in extra_rdoc_files option.
|
147
156
|
* [CHANGE] File `README.md`: Re-formatting so that it is better rendered with darkfish (from YARD).
|
148
|
-
* [CHANGE] File `.yardopts` : grouped the exclude options on one line.
|
157
|
+
* [CHANGE] File `.yardopts` : grouped the exclude options on one line.
|
149
158
|
|
150
159
|
### 0.3.36 / 2013-06-27
|
151
160
|
* [FIX] File `macros4cuke.gemspec`: corrected the rdoc_options to exclude doc from examples, features and spec folders.
|
152
161
|
This was necessary because all but the latest versions of RDoc have difficulties to cope with utf-8.
|
153
|
-
* [CHANGE] File `.yardopts` : added more folders to exclude from documentation generation.
|
162
|
+
* [CHANGE] File `.yardopts` : added more folders to exclude from documentation generation.
|
154
163
|
|
155
164
|
### 0.3.35 / 2013-06-27
|
156
165
|
* [CHANGE] File `macros4cuke.gemspec`: added rdoc_options to exclude doc from examples, features and spec folders.
|
157
|
-
This was necessary because all but the latest versions of RDoc have difficulties to cope with utf-8.
|
166
|
+
This was necessary because all but the latest versions of RDoc have difficulties to cope with utf-8.
|
158
167
|
|
159
168
|
### 0.3.34 / 2013-06-20
|
160
169
|
* [CHANGE] Most files: Except for the i18n sample files, the utf-8 encoding comment was in all Ruby files of the project.
|
@@ -243,7 +252,7 @@
|
|
243
252
|
|
244
253
|
### 0.3.16 / 2013-05-20
|
245
254
|
* [CHANGE] File `demo06.feature`: Added a scenario that causes a specific exception to be raised.
|
246
|
-
* [CHANGE] File `demo_steps.rb`: Added a specific step that raises a TableNotException. It is captured and compared to expectations.
|
255
|
+
* [CHANGE] File `demo_steps.rb`: Added a specific step that raises a TableNotException. It is captured and compared to expectations.
|
247
256
|
* [CHANGE] File `engine.rb`: Removed two lines that were never executed.
|
248
257
|
|
249
258
|
### 0.3.15 / 2013-05-20
|
@@ -289,7 +298,7 @@
|
|
289
298
|
* [NEW] File `.travis.yml`: Added for integration with Travis CI
|
290
299
|
* [NEW] File `Gemfile`: Added for integration with Bundler
|
291
300
|
* [NEW] File `Rakefile`: Added with test tasks
|
292
|
-
* [CHANGE] File `macros4cuke.gemspec`: added development dependency on rake.
|
301
|
+
* [CHANGE] File `macros4cuke.gemspec`: added development dependency on rake.
|
293
302
|
|
294
303
|
### 0.3.03 / 2013-05-11
|
295
304
|
* [CHANGE] File `README.md`: added section on conditional section.
|
@@ -304,7 +313,7 @@
|
|
304
313
|
* [CHANGE] Method `Engine#compile_sction` completed and tested to support section elements.
|
305
314
|
* [CHANGE] Method `Section#variables` expanded to support section elements.
|
306
315
|
* [CHANGE] Method `Engine#variables` expanded to support section elements.
|
307
|
-
* [CHANGE] Method `Engine#compile_line` added two formatting rules.
|
316
|
+
* [CHANGE] Method `Engine#compile_line` added two formatting rules.
|
308
317
|
* [CHANGE] Method `MacroStep#scan_arguments` now un-escape the \" sequence into plain quote.
|
309
318
|
* [CHANGE] examples/ folder expanded and reorganized
|
310
319
|
* [FIX] Method `Section#render` fixed typo in call to __method__
|
@@ -428,7 +437,7 @@
|
|
428
437
|
|
429
438
|
### 0.2.01 / 2013-4-26
|
430
439
|
|
431
|
-
* [CHANGE] Regexps in step definitions accept escape character sequence.
|
440
|
+
* [CHANGE] Regexps in step definitions accept escape character sequence.
|
432
441
|
* [CHANGE] Expanded `README.md` file.
|
433
442
|
* [FIX] Corrected remnant of Mustache template in `travelling_demo.feature` file.
|
434
443
|
|
@@ -457,7 +466,7 @@
|
|
457
466
|
### 0.1.05 / Unreleased
|
458
467
|
|
459
468
|
* [CHANGE] `demo_steps.rb`. Added few step definitions that emit output to the screen (so that at least something is shown in the demo).
|
460
|
-
* [CHANGE] `MacroStep` class: regexp slightly reworked to accept escaped double quotes in actual values.
|
469
|
+
* [CHANGE] `MacroStep` class: regexp slightly reworked to accept escaped double quotes in actual values.
|
461
470
|
* [CHANGE] `travelling_demo.feature`: Added one example with escaped quotes in actual value.
|
462
471
|
|
463
472
|
|
@@ -481,4 +490,4 @@
|
|
481
490
|
|
482
491
|
### 0.0.01 / 2013-04-21
|
483
492
|
|
484
|
-
* [FEATURE] Initial public working version
|
493
|
+
* [FEATURE] Initial public working version
|
data/Gemfile
CHANGED
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -4,7 +4,8 @@ _Extend Cucumber with macro-steps._
|
|
4
4
|
[Homepage](https://github.com/famished-tiger/Macros4Cuke)
|
5
5
|
[Documentation] (https://www.relishapp.com/famished-tiger/macros4cuke/docs)
|
6
6
|
|
7
|
-
[![Build Status](https://travis-ci.org/famished-tiger/Macros4Cuke.png?branch=master)](https://travis-ci.org/famished-tiger/Macros4Cuke)
|
7
|
+
[![Linux Build Status](https://travis-ci.org/famished-tiger/Macros4Cuke.png?branch=master)](https://travis-ci.org/famished-tiger/Macros4Cuke)
|
8
|
+
[![Windows Build status](https://ci.appveyor.com/api/projects/status/amsdudnqo1jqfody?svg=true)](https://ci.appveyor.com/project/famished-tiger/macros4cuke)
|
8
9
|
[![Code Climate](https://codeclimate.com/github/famished-tiger/Macros4Cuke.png)](https://codeclimate.com/github/famished-tiger/Macros4Cuke.png)
|
9
10
|
[![Gem Version](https://badge.fury.io/rb/macros4cuke.png)](http://badge.fury.io/rb/macros4cuke)
|
10
11
|
[![Dependency Status](https://gemnasium.com/famished-tiger/Macros4Cuke.png)](https://gemnasium.com/famished-tiger/Macros4Cuke)
|
@@ -15,17 +16,17 @@ __Macros4Cuke__ is a Cucumber extension that adds a macro facility for your Cucu
|
|
15
16
|
All this can be done directly in your feature files without programming step definitions.
|
16
17
|
|
17
18
|
### Highlights ###
|
18
|
-
* Works with out-of-the-box Cucumber
|
19
|
+
* Works with out-of-the-box Cucumber
|
19
20
|
* Simple installation and setup (no programming required),
|
20
21
|
* Familiar syntax for macro-step definitions,
|
21
|
-
*
|
22
|
+
* Sub-step sequence can be of arbitrary length,
|
22
23
|
* Macro-steps may have data arguments,
|
23
24
|
* Data values can be passed to the sub-steps,
|
24
25
|
* Domain neutral: applicable to any kind of application that can be driven with Cucumber,
|
25
26
|
* A group of sub-steps can be made conditional.
|
26
27
|
|
27
28
|
|
28
|
-
Since version 0.4.00, it is also possible to [list all the encountered macro definitions](#listing-all-the-macro-definitions).
|
29
|
+
Since version 0.4.00, it is also possible to [list all the encountered macro definitions](#listing-all-the-macro-definitions).
|
29
30
|
|
30
31
|
## A quick example ##
|
31
32
|
Here is a macro-step example taken from our demo files:
|
@@ -49,13 +50,13 @@ the macro-step is invoked(used) elsewhere in a feature file.
|
|
49
50
|
|
50
51
|
That macro-step can then be used/invoked in a scenario like this:
|
51
52
|
|
52
|
-
```cucumber
|
53
|
+
```cucumber
|
53
54
|
When I [enter my userid "jdoe" and password "hello-world"]
|
54
55
|
```
|
55
56
|
|
56
57
|
Once it is executing, the invoked macro-step should be equivalent to:
|
57
58
|
|
58
|
-
```cucumber
|
59
|
+
```cucumber
|
59
60
|
Given I landed in the homepage
|
60
61
|
When I click "Sign in"
|
61
62
|
And I fill in "Username" with "jdoe"
|
@@ -84,27 +85,27 @@ Macros4Cuke requires Cucumber.
|
|
84
85
|
### Installation ###
|
85
86
|
The macros4cuke gem installation is fairly standard.
|
86
87
|
If you have a `Gemfile`, add `macros4cuke` to it. Otherwise, install the gem like this:
|
87
|
-
|
88
|
+
|
88
89
|
```bash
|
89
90
|
$[sudo] gem install macros4cuke
|
90
91
|
```
|
91
92
|
|
92
93
|
### Configuring your Cucumber projects ####
|
93
94
|
The procedure to add support for macros in an existing Cucumber project
|
94
|
-
was simplified since version 0.5.00.
|
95
|
-
|
95
|
+
was simplified since version 0.5.00.
|
96
|
+
|
96
97
|
There are two possible ways to do it:
|
97
98
|
- By editing manually a support file; or,
|
98
99
|
- Let Macros4cuke configure your project.
|
99
|
-
|
100
|
+
|
100
101
|
#### Alternative 1: manually add one line in a support file
|
101
102
|
Require the library in one of your ruby files under `features/support` (e.g. `env.rb`):
|
102
|
-
|
103
|
+
|
103
104
|
```ruby
|
104
105
|
# /features/support/env.rb
|
105
106
|
# Add the next single line
|
106
107
|
require 'macros4cuke/cucumber'
|
107
|
-
```
|
108
|
+
```
|
108
109
|
|
109
110
|
That's it! Now you can start writing macros in your Cucumber project.
|
110
111
|
|
@@ -121,7 +122,7 @@ already the directory containing the Cucumber project, then the
|
|
121
122
|
command-line is simply:
|
122
123
|
```bash
|
123
124
|
$[sudo] macros4cuke --setup .
|
124
|
-
```
|
125
|
+
```
|
125
126
|
|
126
127
|
Notice that ending dot above means "the current directory".
|
127
128
|
|
@@ -174,7 +175,7 @@ A phrase can be without argument as in:
|
|
174
175
|
# A phrase without argument
|
175
176
|
[enter my credentials]
|
176
177
|
```
|
177
|
-
|
178
|
+
|
178
179
|
Alternatively, a phrase can have one or more arguments enclosed between chevrons <...>.
|
179
180
|
For instance, the next first phrase has two arguments, the second has three arguments:
|
180
181
|
|
@@ -186,13 +187,13 @@ For instance, the next first phrase has two arguments, the second has three argu
|
|
186
187
|
Each argument (variable) is enclosed between <...> chevrons. In our last example,
|
187
188
|
the argument names are: _origin_ and _destination_. Notice that _origin_ and _destination_ are
|
188
189
|
variable names that will take a value (if any) when the step is invoked _(more on this later)_.
|
189
|
-
|
190
|
+
|
190
191
|
|
191
192
|
#### Specifying the sub-steps of a macro-step ####
|
192
|
-
The sub-steps are placed in a Gherkin multiline text, that is, a text that is enclosed between
|
193
|
+
The sub-steps are placed in a Gherkin multiline text, that is, a text that is enclosed between
|
193
194
|
triple quotes ("""). In the next example,
|
194
195
|
|
195
|
-
```cucumber
|
196
|
+
```cucumber
|
196
197
|
Given I define the step "When I [enter my credentials]" to mean:
|
197
198
|
"""
|
198
199
|
Given I landed in the homepage
|
@@ -201,12 +202,12 @@ The sub-steps are placed in a Gherkin multiline text, that is, a text that is en
|
|
201
202
|
And I click "Sign in"
|
202
203
|
"""
|
203
204
|
```
|
204
|
-
|
205
|
+
|
205
206
|
the text between triple quotes enumerates the sub-steps associated with the macro-step.
|
206
207
|
A pleasing aspect is the familiar syntax the sub-steps have: they closely look to genuine steps of a scenario.
|
207
|
-
Sub-steps can also have macro arguments.
|
208
|
+
Sub-steps can also have macro arguments.
|
208
209
|
For instance, the previous step sequence could have two arguments called _userid_ and _password_:
|
209
|
-
|
210
|
+
|
210
211
|
```cucumber
|
211
212
|
"""
|
212
213
|
Given I landed in the homepage
|
@@ -214,7 +215,7 @@ Sub-steps can also have macro arguments.
|
|
214
215
|
And I fill in "Password" with "<password>"
|
215
216
|
And I click "Sign in"
|
216
217
|
"""
|
217
|
-
```
|
218
|
+
```
|
218
219
|
|
219
220
|
### Using (invoking) a macro-step ###
|
220
221
|
A macro-step can only be invoked after its definition has been read by Cucumber.
|
@@ -226,7 +227,7 @@ The syntax rules for using a given macro-step in a scenario are pretty straightf
|
|
226
227
|
Consider the following macro-step definition:
|
227
228
|
|
228
229
|
```cucumber
|
229
|
-
Given I define the step "When I [log in as <userid>]" to mean:
|
230
|
+
Given I define the step "When I [log in as <userid>]" to mean:
|
230
231
|
"""
|
231
232
|
# Sub-steps come here...
|
232
233
|
"""
|
@@ -234,7 +235,7 @@ Consider the following macro-step definition:
|
|
234
235
|
|
235
236
|
Its quoted sentence is ```"When I [log in as <userid>]"```, therefore
|
236
237
|
the macro-step can be invoked in a scenario like this:
|
237
|
-
|
238
|
+
|
238
239
|
```cucumber
|
239
240
|
Given I do this ...
|
240
241
|
When I [log in as "jdoe"]
|
@@ -245,7 +246,7 @@ Its quoted sentence is ```"When I [log in as <userid>]"```, therefore
|
|
245
246
|
Here is another -partial- macro-step definition:
|
246
247
|
|
247
248
|
```cucumber
|
248
|
-
Given I define the step "When I [travel from <origin> to <destination> via <stop>]" to mean:
|
249
|
+
Given I define the step "When I [travel from <origin> to <destination> via <stop>]" to mean:
|
249
250
|
"""
|
250
251
|
# Sub-steps come here...
|
251
252
|
"""
|
@@ -293,17 +294,17 @@ This step can be used like this:
|
|
293
294
|
|city| Old White Castle|
|
294
295
|
|postcode|JK345|
|
295
296
|
```
|
296
|
-
|
297
|
+
|
297
298
|
Here are few observations worth noticing:
|
298
299
|
- The data table has two columns.
|
299
300
|
- Each row is of the form: |argument name| actual value|. For instance, the argument _street_address_ takes
|
300
301
|
the value "Main Street, 22".
|
301
|
-
- Data rows don't have to follow strictly the order of the arguments in the sub-step sequence.
|
302
|
+
- Data rows don't have to follow strictly the order of the arguments in the sub-step sequence.
|
302
303
|
|
303
304
|
## Macro-step arguments ##
|
304
305
|
|
305
306
|
### Argument names ###
|
306
|
-
In line with most computer languages, Macros4Cuke accepts argument names containing alphanumeric characters and
|
307
|
+
In line with most computer languages, Macros4Cuke accepts argument names containing alphanumeric characters and
|
307
308
|
underscores.
|
308
309
|
In fact, the only characters that are not allowed in argument names are the following punctuation or delimiting
|
309
310
|
signs:
|
@@ -315,7 +316,7 @@ An argument appearing in the phrase MUST always be bound to a value at the step
|
|
315
316
|
Taking again a previous example of a -partial- macro-step definition:
|
316
317
|
|
317
318
|
```cucumber
|
318
|
-
Given I define the step "When I [travel from <origin> to <destination> via <stop>]" to mean:
|
319
|
+
Given I define the step "When I [travel from <origin> to <destination> via <stop>]" to mean:
|
319
320
|
"""
|
320
321
|
# Sub-steps come here...
|
321
322
|
"""
|
@@ -334,7 +335,7 @@ The next invokation is syntactically correct for Macros4Cuke:
|
|
334
335
|
When I [travel from "San Francisco" to "" via "Las Vegas"]
|
335
336
|
```
|
336
337
|
|
337
|
-
The _destination_ argument gets an empty text as actual value.
|
338
|
+
The _destination_ argument gets an empty text as actual value.
|
338
339
|
|
339
340
|
For any argument that can receive a value through a data table, three situations can occur:
|
340
341
|
1. A row for that argument together with a text value are specified at invokation. The argument is bound to that text value.
|
@@ -361,7 +362,7 @@ Consider the following attempt of a macro-step definition:
|
|
361
362
|
```
|
362
363
|
|
363
364
|
This will result in an error. The issue is caused by the nesting of triple quotes:
|
364
|
-
Cucumber simply doesn't allow this. In fact, the error is reported by [Gherkin](https://github.com/cucumber/gherkin),
|
365
|
+
Cucumber simply doesn't allow this. In fact, the error is reported by [Gherkin](https://github.com/cucumber/gherkin),
|
365
366
|
a component used by Cucumber.
|
366
367
|
As Gherkin has other [issues](https://github.com/cucumber/gherkin/issues/124) with docstrings, we
|
367
368
|
need a workaround today until the fixes are applied.
|
@@ -387,8 +388,8 @@ Thus to make the previous example work, one must change it like follows:
|
|
387
388
|
|
388
389
|
## Conditional sections in substeps. ##
|
389
390
|
To make the macros more flexible, it is possible to define conditional sections in the substep sequence.
|
390
|
-
The general pattern for the conditional section is:
|
391
|
-
|
391
|
+
The general pattern for the conditional section is:
|
392
|
+
|
392
393
|
```cucumber
|
393
394
|
<?foobar>
|
394
395
|
substep1
|
@@ -423,7 +424,7 @@ Consider the following example:
|
|
423
424
|
```
|
424
425
|
|
425
426
|
When invoked like this:
|
426
|
-
|
427
|
+
|
427
428
|
```cucumber
|
428
429
|
When I [fill in the form with]:
|
429
430
|
|firstname |Alice|
|
@@ -454,7 +455,7 @@ the email macro argument.
|
|
454
455
|
|
455
456
|
|
456
457
|
A typical use case for conditional sections is to prevent the execution of one or more steps in
|
457
|
-
absence of a given data item. This simulates, for instance, the behaviour of a user that skips
|
458
|
+
absence of a given data item. This simulates, for instance, the behaviour of a user that skips
|
458
459
|
one or more widgets in a page/screen. From a user interface testing viewpoint, entering an empty
|
459
460
|
text in an entry field may be noticeably different than skipping that same entry field.
|
460
461
|
Think of specific UI-events that can trigger some special system response.
|
@@ -480,7 +481,7 @@ This specialized step has the following syntax:
|
|
480
481
|
```
|
481
482
|
|
482
483
|
Where `all_macros.feature` is a feature file that will be generated when Cucumber
|
483
|
-
terminates. The resulting feature file lists all the macros (one per scenario) in
|
484
|
+
terminates. The resulting feature file lists all the macros (one per scenario) in
|
484
485
|
the familiar Gherkin syntax. The file is placed in the current directory (i.e. the directory where
|
485
486
|
Cucumber was launched).
|
486
487
|
|
@@ -488,12 +489,12 @@ Cucumber was launched).
|
|
488
489
|
|
489
490
|
## A word on Step Argument Transforms##
|
490
491
|
Cucumber provides a handy facility that helps to convert implicitly the values of step arguments.
|
491
|
-
A first description of this lesser-known functionality is available at
|
492
|
+
A first description of this lesser-known functionality is available at
|
492
493
|
[Step Argument Transforms] (https://github.com/cucumber/cucumber/wiki/Step-Argument-Transforms).
|
493
494
|
Does Macros4Cuke provide such a facility for its own macro-step arguments?
|
494
495
|
The answer is no: if macro-steps had their own kind of transformations, then these would have interfere with the ones defined directly in Cucumber.
|
495
496
|
In fact, Cucumber will happily apply transformations on any step, including the macro definition steps and the
|
496
|
-
steps invoking macros. Stated otherwise, all the rules pertaining to the Step Argument Transforms work as usual. Or almost.
|
497
|
+
steps invoking macros. Stated otherwise, all the rules pertaining to the Step Argument Transforms work as usual. Or almost.
|
497
498
|
There is one very specific case where Cucumber behaves slightly differently: the transforms aren't applied when a sub-step is executed.
|
498
499
|
Internally, Macros4Cuke calls the `Cucumber::RbSupport::RbWorld::#steps` method that allows to run a Gherkin snippet (the substeps),
|
499
500
|
and it appears that this method does not trigger the transforms. In practice, this doesn't prevent the use of transforms together
|
@@ -503,7 +504,7 @@ with Macros4Cuke. In the vast majority of cases both will work fine as expected.
|
|
503
504
|
## FAQ ##
|
504
505
|
__Q__: Can I define a macro in one scenario and invoke it in another scenario in the same feature file?
|
505
506
|
__A__: Yes. Once a macro is defined in a feature file it can be invoked in any scenario that follows the definition.
|
506
|
-
In fact, the macro can be invoked in any scenario from any feature file, provided the invokation takes place _after_ the
|
507
|
+
In fact, the macro can be invoked in any scenario from any feature file, provided the invokation takes place _after_ the
|
507
508
|
macro definition.
|
508
509
|
|
509
510
|
__Q__: So, a macro can be shared between multiple files.
|
@@ -518,7 +519,7 @@ __Q__: Can I define a macro-step in a `Background` section?
|
|
518
519
|
__A__: No. Here is why: every step from the Background section is executed in each scenario (outline).
|
519
520
|
If a macro were defined in the Background, then the macro definition will occur multiple times, which is
|
520
521
|
flagged as an error by Macros4Cuke.
|
521
|
-
|
522
|
+
|
522
523
|
__Q__: Can I define a macro-step in a `Scenario Outline`?
|
523
524
|
__A__: No, if the scenario outline has multiple rows then an error will occur. Bear in mind,
|
524
525
|
that steps in a scenario outline are repeating n times, n being the number of rows in the example table.
|
@@ -533,7 +534,7 @@ __A__: Yes. As a macro-step can be invoked multiple times.
|
|
533
534
|
## Changelog
|
534
535
|
|
535
536
|
Macros4Cuke's changelog is available [here](CHANGELOG.md).
|
536
|
-
|
537
|
+
|
537
538
|
## More resources:
|
538
539
|
- [**Detailed CI status**](https://travis-ci.org/famished-tiger/Macros4Cuke)
|
539
540
|
- [**Suggest an improvement**](https://github.com/famished-tiger/Macros4Cuke/issues)
|
@@ -550,7 +551,7 @@ In addition __Macros4Cuke__ allows advanced users to craft their own steps witho
|
|
550
551
|
This last argument becomes important in the context of user acceptance testing, a domain where the assumption that
|
551
552
|
every tester is also Rubyist is -alas!- far from the truth.
|
552
553
|
|
553
|
-
|
554
|
+
|
554
555
|
Macros with Cucumber is a hot topic, so it is good to know what other people say about it:
|
555
556
|
[Support for Macros] (https://github.com/cucumber/gherkin/issues/178)
|
556
557
|
[Substeps - macro request for the nth time] (http://grokbase.com/t/gg/cukes/133ey063b8/cucumber-substeps-macro-request-for-the-nth-time)
|
@@ -558,4 +559,4 @@ Macros with Cucumber is a hot topic, so it is good to know what other people say
|
|
558
559
|
|
559
560
|
Copyright
|
560
561
|
---------
|
561
|
-
Copyright (c) 2014-
|
562
|
+
Copyright (c) 2014-2017, Dimitri Geshef. Macros4Cuke is released under the MIT License see [LICENSE.txt](https://github.com/famished-tiger/Macros4Cuke/blob/master/LICENSE.txt) for details.
|
data/Rakefile
CHANGED
@@ -1,54 +1,54 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require_relative './lib/macros4cuke/constants'
|
3
|
-
|
4
|
-
namespace :gem do
|
5
|
-
desc 'Push the gem to rubygems.org'
|
6
|
-
task :push do
|
7
|
-
system("gem push macros4cuke-#{Macros4Cuke::Version}.gem")
|
8
|
-
end
|
9
|
-
end # namespace
|
10
|
-
|
11
|
-
# Testing-specific tasks
|
12
|
-
|
13
|
-
# Cucumber as testing tool
|
14
|
-
require 'cucumber/rake/task'
|
15
|
-
# UGLY workaround for bug in Cucumber's rake task
|
16
|
-
if Gem::VERSION[0].to_i >= 2 && Cucumber::VERSION <= '1.3.2'
|
17
|
-
# Monkey-patch a buggy method
|
18
|
-
module Cucumber
|
19
|
-
module Rake
|
20
|
-
class Task
|
21
|
-
class ForkedCucumberRunner
|
22
|
-
def gem_available?(gemname)
|
23
|
-
if Gem::VERSION[0].to_i >= 2
|
24
|
-
gem_available_new_rubygems?(gemname)
|
25
|
-
else
|
26
|
-
gem_available_old_rubygems?(gemname)
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end # class
|
30
|
-
end # class
|
31
|
-
end # module
|
32
|
-
end # module
|
33
|
-
end
|
34
|
-
|
35
|
-
Cucumber::Rake::Task.new do |_|
|
36
|
-
end
|
37
|
-
|
38
|
-
# RSpec as testing tool
|
39
|
-
require 'rspec/core/rake_task'
|
40
|
-
desc 'Run RSpec'
|
41
|
-
RSpec::Core::RakeTask.new do |spec|
|
42
|
-
spec.pattern = 'spec/**/*_spec.rb'
|
43
|
-
end
|
44
|
-
|
45
|
-
|
46
|
-
# Combine RSpec and Cucumber tests
|
47
|
-
desc 'Run tests, with RSpec and Cucumber'
|
48
|
-
task test: [:spec, :cucumber]
|
49
|
-
|
50
|
-
|
51
|
-
# Default rake task
|
52
|
-
task default: :test
|
53
|
-
|
54
|
-
# End of file
|
1
|
+
require 'rubygems'
|
2
|
+
require_relative './lib/macros4cuke/constants'
|
3
|
+
|
4
|
+
namespace :gem do
|
5
|
+
desc 'Push the gem to rubygems.org'
|
6
|
+
task :push do
|
7
|
+
system("gem push macros4cuke-#{Macros4Cuke::Version}.gem")
|
8
|
+
end
|
9
|
+
end # namespace
|
10
|
+
|
11
|
+
# Testing-specific tasks
|
12
|
+
|
13
|
+
# Cucumber as testing tool
|
14
|
+
require 'cucumber/rake/task'
|
15
|
+
# UGLY workaround for bug in Cucumber's rake task
|
16
|
+
if Gem::VERSION[0].to_i >= 2 && Cucumber::VERSION <= '1.3.2'
|
17
|
+
# Monkey-patch a buggy method
|
18
|
+
module Cucumber
|
19
|
+
module Rake
|
20
|
+
class Task
|
21
|
+
class ForkedCucumberRunner
|
22
|
+
def gem_available?(gemname)
|
23
|
+
if Gem::VERSION[0].to_i >= 2
|
24
|
+
gem_available_new_rubygems?(gemname)
|
25
|
+
else
|
26
|
+
gem_available_old_rubygems?(gemname)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end # class
|
30
|
+
end # class
|
31
|
+
end # module
|
32
|
+
end # module
|
33
|
+
end
|
34
|
+
|
35
|
+
Cucumber::Rake::Task.new do |_|
|
36
|
+
end
|
37
|
+
|
38
|
+
# RSpec as testing tool
|
39
|
+
require 'rspec/core/rake_task'
|
40
|
+
desc 'Run RSpec'
|
41
|
+
RSpec::Core::RakeTask.new do |spec|
|
42
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
43
|
+
end
|
44
|
+
|
45
|
+
|
46
|
+
# Combine RSpec and Cucumber tests
|
47
|
+
desc 'Run tests, with RSpec and Cucumber'
|
48
|
+
task test: [:spec, :cucumber]
|
49
|
+
|
50
|
+
|
51
|
+
# Default rake task
|
52
|
+
task default: :test
|
53
|
+
|
54
|
+
# End of file
|
data/appveyor.yml
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
version: '{build}'
|
2
|
+
max_jobs: 3
|
3
|
+
environment:
|
4
|
+
matrix:
|
5
|
+
- Ruby_version: 200
|
6
|
+
- Ruby_version: 200-x64
|
7
|
+
- Ruby_version: 21
|
8
|
+
- Ruby_version: 21-x64
|
9
|
+
- Ruby_version: 22
|
10
|
+
- Ruby_version: 22-x64
|
11
|
+
- Ruby_version: 23
|
12
|
+
- Ruby_version: 23-x64
|
13
|
+
install:
|
14
|
+
- cmd: >-
|
15
|
+
SET PATH=C:\Ruby%Ruby_version%\bin;%PATH%
|
16
|
+
|
17
|
+
bundle install --retry=3 --clean
|
18
|
+
build: off
|
19
|
+
test_script:
|
20
|
+
- cmd: bundle exec rake
|
data/bin/macros4cuke
CHANGED
@@ -1,15 +1,14 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# File: macros4cuke
|
3
|
-
# The 'executable' of the Macros4Cuke library.
|
4
|
-
|
5
|
-
|
6
|
-
lib_dir
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
app
|
13
|
-
|
14
|
-
|
15
|
-
# End of file
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# File: macros4cuke
|
3
|
+
# The 'executable' of the Macros4Cuke library.
|
4
|
+
mydir = File.dirname(__FILE__)
|
5
|
+
lib_dir = mydir + '/../lib'
|
6
|
+
$LOAD_PATH.unshift lib_dir unless $LOAD_PATH.include?(lib_dir)
|
7
|
+
|
8
|
+
require 'macros4cuke' # Load the Cukedep::Application class
|
9
|
+
|
10
|
+
# The application's entry point
|
11
|
+
app = Macros4Cuke::Application.new
|
12
|
+
app.run!(ARGV.dup)
|
13
|
+
|
14
|
+
# End of file
|
data/lib/macro_steps.rb
CHANGED
@@ -34,7 +34,7 @@ end
|
|
34
34
|
# When I [log in as "guest"]
|
35
35
|
#
|
36
36
|
When(/^I \[((?:[^\\\]]|\\.)+)\]$/) do |macro_phrase|
|
37
|
-
invoke_macro(macro_phrase)
|
37
|
+
invoke_macro(macro_phrase) # This will call the macro with the given phrase
|
38
38
|
end
|
39
39
|
|
40
40
|
|
@@ -47,9 +47,9 @@ end
|
|
47
47
|
# |password|unguessable|
|
48
48
|
When(/^I \[([^\]]+)\]:$/) do |macro_phrase, table_argument|
|
49
49
|
# Ensure that the second argument is of the correct type
|
50
|
-
#unless table_argument.is_a?(Cucumber::Ast::Table)
|
50
|
+
# unless table_argument.is_a?(Cucumber::Ast::Table)
|
51
51
|
unless table_argument.is_a?(Cucumber::MultilineArgument::DataTable)
|
52
|
-
|
52
|
+
raise(Macros4Cuke::DataTableNotFound.new(macro_phrase))
|
53
53
|
end
|
54
54
|
|
55
55
|
# This will call the macro with the given phrase.
|
@@ -9,8 +9,6 @@ module Macros4Cuke # Module used as a namespace
|
|
9
9
|
class Application
|
10
10
|
attr_reader(:options)
|
11
11
|
|
12
|
-
public
|
13
|
-
|
14
12
|
def initialize()
|
15
13
|
@options = {}
|
16
14
|
end
|
@@ -43,7 +41,7 @@ class Application
|
|
43
41
|
destination = prefix + aPath.to_s + '/' + file_name + '.rb'
|
44
42
|
|
45
43
|
begin
|
46
|
-
|
44
|
+
raise SupportFileExists.new(destination) if File.exist?(destination)
|
47
45
|
|
48
46
|
template_pathname =
|
49
47
|
Macros4Cuke::RootDir + 'templates/use_macros4cuke.erb'
|