macros4cuke 0.3.01 → 0.3.02
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +3 -0
- data/lib/macro_steps.rb +50 -0
- data/lib/macros4cuke/constants.rb +1 -1
- metadata +3 -2
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
## 0.3.02 / 2013-05-11
|
2
|
+
* [FIX] File `macro_steps.rb`: Recovered. Was missing in the 0.3.01 distribution!
|
3
|
+
|
1
4
|
## 0.3.01 / 2013-05-10
|
2
5
|
* [NEW] features/ folder: added `demo06.feature` file showing the new conditional section.
|
3
6
|
* [NEW] File `placeholder_spec.rb`: Added a RSpec file to test the Placeholder class.
|
data/lib/macro_steps.rb
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
# File: macro_steps.rb
|
2
|
+
# Purpose: step definitions that help to build macro-steps (i.e. a step that is equivalent to a sequence of steps)
|
3
|
+
|
4
|
+
|
5
|
+
|
6
|
+
# This step is used to define a macro-step
|
7
|
+
# Example:
|
8
|
+
# Given I define the step "When I [log in as <userid>]" to mean:
|
9
|
+
# """
|
10
|
+
# Given I landed in the homepage
|
11
|
+
# When I click "Sign in"
|
12
|
+
# And I fill in "Username" with "<userid>"
|
13
|
+
# And I fill in "Password" with "unguessable"
|
14
|
+
# And I click "Submit"
|
15
|
+
# """
|
16
|
+
# The regexp has two capturing group: one for the phrase, a second for the terminating colon (:)
|
17
|
+
Given(/^I define the step "(?:Given|When|Then|\*) I \[((?:[^\\\]]|\\.)+)\](:?)" to mean:$/) do |macro_phrase, colon_capture, template|
|
18
|
+
use_table = (colon_capture == ':')
|
19
|
+
add_macro(macro_phrase, template, use_table)
|
20
|
+
end
|
21
|
+
|
22
|
+
|
23
|
+
|
24
|
+
# This step is used to invoke a simple macro-step
|
25
|
+
# Example:
|
26
|
+
# When I [log in as "guest"]
|
27
|
+
#
|
28
|
+
When(/^I \[((?:[^\\\]]|\\.)+)\]$/) do |macro_phrase|
|
29
|
+
invoke_macro(macro_phrase) # This will call the macro with the given phrase
|
30
|
+
end
|
31
|
+
|
32
|
+
|
33
|
+
# This step is used to invoke a macro-step with a data table argument.
|
34
|
+
# Example:
|
35
|
+
# When I [enter my credentials as]:
|
36
|
+
# |userid |guest |
|
37
|
+
# |password|unguessable|
|
38
|
+
When(/^I \[([^\]]+)\]:$/) do |macro_phrase, table_argument|
|
39
|
+
# Ensure that the second argument is of the correct type
|
40
|
+
unless table_argument.kind_of?(Cucumber::Ast::Table)
|
41
|
+
raise Macros4Cuke::DataTableNotFound, "This step must have a data table as an argument."
|
42
|
+
end
|
43
|
+
|
44
|
+
# This will call the macro with the given phrase.
|
45
|
+
# The second argument consists of an array with couples of the kind: [argument name, actual value]
|
46
|
+
invoke_macro(macro_phrase, table_argument.raw)
|
47
|
+
end
|
48
|
+
|
49
|
+
|
50
|
+
# End of file
|
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.02
|
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-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: cucumber
|
@@ -72,6 +72,7 @@ files:
|
|
72
72
|
- LICENSE.txt
|
73
73
|
- README.md
|
74
74
|
- lib/macros4cuke.rb
|
75
|
+
- lib/macro_steps.rb
|
75
76
|
- lib/macros4cuke/constants.rb
|
76
77
|
- lib/macros4cuke/exceptions.rb
|
77
78
|
- lib/macros4cuke/macro-collection.rb
|