macros4cuke 0.3.09 → 0.3.10
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +4 -0
- data/README.md +26 -1
- data/lib/macros4cuke/constants.rb +1 -1
- data/lib/macros4cuke/templating/engine.rb +28 -23
- metadata +3 -3
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
## 0.3.10 / 2013-05-14
|
2
|
+
* [CHANGE] File `README.md`: Expanded section on conditional section.
|
3
|
+
* [CHANGE] Method `Templating::Engine::parse` slightly refactored in order to decrease its complexity.
|
4
|
+
|
1
5
|
## 0.3.09 / 2013-05-13
|
2
6
|
* [CHANGE] File `.travis.yml`: Added jruby as a target Ruby
|
3
7
|
|
data/README.md
CHANGED
@@ -338,7 +338,32 @@ When invoked like this:
|
|
338
338
|
|country|Wonderland|
|
339
339
|
```
|
340
340
|
|
341
|
-
the substep
|
341
|
+
the following substep sequence is executed:
|
342
|
+
```cucumber
|
343
|
+
When I fill in "first_name" with "Alice"
|
344
|
+
And I fill in "last_name" with "Inn"
|
345
|
+
And I fill in "street_address" with "11, No Street"
|
346
|
+
And I fill in "zip" with ""
|
347
|
+
And I fill in "city" with "Nowhere-City"
|
348
|
+
And I click "Save"
|
349
|
+
```
|
350
|
+
|
351
|
+
A few remarks concerning the executed sequence:
|
352
|
+
1. Every macro argument (say, firstname) that takes a value (say, "Alice"), is replaced
|
353
|
+
that by that value in the substeps.
|
354
|
+
2. Every macro argument (say, zip) that doesn't have a corresponding row in the data table,
|
355
|
+
is replaced by an empty text (look at the substep for the zip code entry).
|
356
|
+
3. The substep with the email entry doesn't appear at all. This can be explained by the conditional
|
357
|
+
section <?email>...</email> that prevents the enclosed substep(s) to be generated in absence of a value for
|
358
|
+
the email macro argument.
|
359
|
+
|
360
|
+
|
361
|
+
A typical use case for conditional sections is to prevent the execution of one or more steps in
|
362
|
+
absence of a given data item. This simulates, for instance, the behaviour of a user that skips
|
363
|
+
one or more widgets in a page/screen. From a user interface testing viewpoint, entering an empty
|
364
|
+
text in an entry field may be noticeably different than skipping that same entry field.
|
365
|
+
Think of specific UI-events that can trigger some special system response.
|
366
|
+
|
342
367
|
|
343
368
|
|
344
369
|
|
@@ -288,35 +288,40 @@ public
|
|
288
288
|
|
289
289
|
# ... or scan plain text at current position
|
290
290
|
text_literal = scanner.scan(/(?:[^\\<>]|\\.)+/)
|
291
|
-
result << [:static, text_literal] unless text_literal.nil?
|
292
|
-
|
293
|
-
if tag_literal.nil? && text_literal.nil?
|
294
|
-
# Unsuccessful scanning: we have improperly balanced chevrons.
|
295
|
-
# We will analyze the opening and closing chevrons...
|
296
|
-
no_escaped = aTextLine.gsub(/\\[<>]/, "--") # First: replace escaped chevron(s)
|
297
|
-
unbalance = 0 # = count of < - count of > (can only be 0 or -temporarily- 1)
|
298
|
-
|
299
|
-
no_escaped.scan(/(.)/) do |match|
|
300
|
-
case match[0]
|
301
|
-
when '<'
|
302
|
-
unbalance += 1
|
303
|
-
when '>'
|
304
|
-
unbalance -= 1
|
305
|
-
end
|
306
|
-
|
307
|
-
raise StandardError, "Nested opening chevron '<'." if unbalance > 1
|
308
|
-
raise StandardError, "Missing opening chevron '<'." if unbalance < 0
|
309
|
-
end
|
310
|
-
|
311
|
-
raise StandardError, "Missing closing chevron '>'." if unbalance == 1
|
312
|
-
raise StandardError, "Cannot parse:\n'#{aTextLine}'"
|
313
|
-
end
|
291
|
+
result << [:static, text_literal] unless text_literal.nil?
|
292
|
+
identify_parse_error(aTextLine) if tag_literal.nil? && text_literal.nil?
|
314
293
|
end
|
315
294
|
|
316
295
|
return result
|
317
296
|
end
|
318
297
|
|
319
298
|
private
|
299
|
+
# Called when the given text line could not be parsed.
|
300
|
+
# Raises an exception with the syntax issue identified.
|
301
|
+
# @param aTextLine [String] A text line from the template.
|
302
|
+
def self.identify_parse_error(aTextLine)
|
303
|
+
# Unsuccessful scanning: we typically have improperly balanced chevrons.
|
304
|
+
# We will analyze the opening and closing chevrons...
|
305
|
+
no_escaped = aTextLine.gsub(/\\[<>]/, "--") # First: replace escaped chevron(s)
|
306
|
+
unbalance = 0 # This variable equals: count of < - count of > (can only be 0 or -temporarily- 1)
|
307
|
+
|
308
|
+
no_escaped.scan(/(.)/) do |match|
|
309
|
+
case match[0]
|
310
|
+
when '<'
|
311
|
+
unbalance += 1
|
312
|
+
when '>'
|
313
|
+
unbalance -= 1
|
314
|
+
end
|
315
|
+
|
316
|
+
raise StandardError, "Nested opening chevron '<'." if unbalance > 1
|
317
|
+
raise StandardError, "Missing opening chevron '<'." if unbalance < 0
|
318
|
+
end
|
319
|
+
|
320
|
+
raise StandardError, "Missing closing chevron '>'." if unbalance == 1
|
321
|
+
raise StandardError, "Cannot parse:\n'#{aTextLine}'"
|
322
|
+
end
|
323
|
+
|
324
|
+
|
320
325
|
# Create the internal representation of the given template.
|
321
326
|
def compile(aSourceTemplate)
|
322
327
|
# Split the input text into lines.
|
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.10
|
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-05-
|
12
|
+
date: 2013-05-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: cucumber
|
@@ -75,7 +75,7 @@ dependencies:
|
|
75
75
|
- - ! '>='
|
76
76
|
- !ruby/object:Gem::Version
|
77
77
|
version: 0.5.0
|
78
|
-
description: Create your own
|
78
|
+
description: Create your own macro-steps directly in Cucumber scenarios.
|
79
79
|
email:
|
80
80
|
executables: []
|
81
81
|
extensions: []
|