macros4cuke 0.3.28 → 0.3.29
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +5 -0
- data/README.md +18 -9
- data/lib/macros4cuke/constants.rb +1 -1
- data/lib/macros4cuke/macro-step.rb +17 -5
- metadata +2 -2
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
### 0.3.29 / 2013-06-05
|
2
|
+
* [CHANGE] `MacroStep#validate_params` method: `Extract Method` Refactoring, resulting in new method `MacroStep#validate_row`.
|
3
|
+
* [CHANGE] `README.md`: Few editorial changes. Added section `More resources`.
|
4
|
+
|
5
|
+
|
1
6
|
### 0.3.28 / 2013-06-03
|
2
7
|
* [CHANGE] `macros4cuke.gemspec`: Dependencies. Increased version number of RSpec to 2.11.0 (needed after switching to the expect syntax).
|
3
8
|
* [CHANGE] `Gemfile`: Dependencies. Increased version number of RSpec to 2.11.0.
|
data/README.md
CHANGED
@@ -65,14 +65,14 @@ Macros4Cuke works with:
|
|
65
65
|
- JRuby (was tested with version 1.7.3 and above).
|
66
66
|
|
67
67
|
### Installation ###
|
68
|
-
|
68
|
+
The macros4cuke gem is fairly standard:
|
69
69
|
```bash
|
70
70
|
$[sudo] gem install macros4cuke
|
71
71
|
```
|
72
72
|
|
73
|
-
###
|
73
|
+
### Configuring up your Cucumber projects ####
|
74
74
|
|
75
|
-
* Step 1: Add support for macros in
|
75
|
+
* Step 1: Add support for macros in an existing Cucumber project
|
76
76
|
|
77
77
|
```ruby
|
78
78
|
# /features/support/env.rb
|
@@ -425,21 +425,30 @@ __Q__: How should I pass arguments: via the phrase or a data table?
|
|
425
425
|
__A__: Both data passing mechanisms can be used at the same time. Favour data value passing
|
426
426
|
via the phrase when the number of macro arguments is small (say, <= 2).
|
427
427
|
|
428
|
-
__Q__: Can I define a macro-step in a Background section?
|
429
|
-
__A__: No. Here is why:
|
428
|
+
__Q__: Can I define a macro-step in a `Background` section?
|
429
|
+
__A__: No. Here is why: every step from the Background section is executed in each scenario (outline).
|
430
430
|
If a macro were defined in the Background, then the macro definition will occur multiple times, which is
|
431
431
|
flagged as an error by Macros4Cuke.
|
432
432
|
|
433
|
-
__Q__: Can I define a macro-step in a Scenario Outline
|
433
|
+
__Q__: Can I define a macro-step in a `Scenario Outline`?
|
434
434
|
__A__: No, if the scenario outline has multiple rows then an error will occur. Bear in mind,
|
435
435
|
that steps in a scenario outline are repeating n times, n being the number of rows in the example table.
|
436
436
|
Since a macro can only be defined once, placing a macro definition in a scenario outline will
|
437
437
|
most likely cause an error.
|
438
438
|
|
439
|
-
__Q__: Can I
|
440
|
-
__A__: Yes.
|
439
|
+
__Q__: Can I __invoke/call__ a macro-step in a `Background` or `Scenario Outline`?
|
440
|
+
__A__: Yes. As a macro-step can be invoked multiple times.
|
441
441
|
|
442
442
|
|
443
|
+
## Changelog
|
444
|
+
|
445
|
+
Macros4Cuke's changelog is available [here](CHANGELOG.md).
|
446
|
+
|
447
|
+
## More resources:
|
448
|
+
- [**Detailed CI status**](https://travis-ci.org/famished-tiger/Macros4Cuke)
|
449
|
+
- [**Suggest an improvement**](https://github.com/famished-tiger/Macros4Cuke/issues)
|
450
|
+
- [**Report a bug**](https://github.com/famished-tiger/Macros4Cuke/issues)
|
451
|
+
|
443
452
|
|
444
453
|
## With great power comes great responsibility. ##
|
445
454
|
_Stan Lee_
|
@@ -452,7 +461,7 @@ This last argument becomes important in the context of user acceptance testing,
|
|
452
461
|
every tester is also Rubyist is -alas!- far from the truth.
|
453
462
|
|
454
463
|
|
455
|
-
Macros with Cucumber is
|
464
|
+
Macros with Cucumber is a hot topic, so it is good to know what other people say about it:
|
456
465
|
[Support for Macros] (https://github.com/cucumber/gherkin/issues/178)
|
457
466
|
[Substeps - macro request for the nth time] (http://grokbase.com/t/gg/cukes/133ey063b8/cucumber-substeps-macro-request-for-the-nth-time)
|
458
467
|
|
@@ -142,11 +142,8 @@ private
|
|
142
142
|
end
|
143
143
|
|
144
144
|
unless rawData.nil?
|
145
|
-
rawData.each do |
|
146
|
-
|
147
|
-
if (phrase_args.include? a_key) && (macro_parameters[a_key] != value)
|
148
|
-
raise AmbiguousArgumentValue.new(a_key, macro_parameters[a_key], value)
|
149
|
-
end
|
145
|
+
rawData.each do |a_row|
|
146
|
+
(a_key, value) = validate_row(a_row, macro_parameters)
|
150
147
|
if macro_parameters.include? a_key
|
151
148
|
if macro_parameters[a_key].kind_of?(Array)
|
152
149
|
macro_parameters[a_key] << value
|
@@ -161,6 +158,21 @@ private
|
|
161
158
|
|
162
159
|
return macro_parameters
|
163
160
|
end
|
161
|
+
|
162
|
+
# Validate a row from the data table.
|
163
|
+
# Return the validated row.
|
164
|
+
# @param a_row [Array] A 2-elements Array (i.e. a couple) of the form:
|
165
|
+
# [macro argument name, a value].
|
166
|
+
# @param value [Hash] The pairs phrase argument name => value
|
167
|
+
def validate_row(a_row, phrase_params)
|
168
|
+
(a_key, value) = a_row
|
169
|
+
raise UnknownArgumentError.new(a_key) unless args.include? a_key
|
170
|
+
if (phrase_args.include? a_key) && (phrase_params[a_key] != value)
|
171
|
+
raise AmbiguousArgumentValue.new(a_key, phrase_params[a_key], value)
|
172
|
+
end
|
173
|
+
|
174
|
+
return a_row
|
175
|
+
end
|
164
176
|
|
165
177
|
|
166
178
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: macros4cuke
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.29
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-06-
|
12
|
+
date: 2013-06-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: cucumber
|