parfait 0.10.0 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/parfait/application.rb +2 -3
- data/lib/parfait/artifact.rb +49 -16
- data/lib/parfait/control.rb +2 -3
- data/lib/parfait/page.rb +3 -6
- data/lib/parfait/region.rb +4 -7
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6ff8e6fb73203bae5fb8b29221e8036e767d6756
|
4
|
+
data.tar.gz: 5d6768bc076105db4c642d6cbc3fc8324226a4cb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a01841f001507aa28b88ddfccc9354fa39c6e83b6a9b5b9388622dde4f70b100b7c9a74a6e3e2df3bf401872798c03fde690d423ad63e18ede57b2c02c36ce4c
|
7
|
+
data.tar.gz: 19bf23e43506aeade6863e1fc0b50047a25e92baa2c772be9bff8100f6acf2efae4b74491cff3c440cb2b621df57321bb5cbf031382bf0b64915dee5710605d3
|
data/lib/parfait/application.rb
CHANGED
@@ -34,6 +34,7 @@ module Parfait
|
|
34
34
|
|
35
35
|
@pages = Hash.new
|
36
36
|
@@all[@name] = self
|
37
|
+
super
|
37
38
|
end
|
38
39
|
|
39
40
|
|
@@ -142,9 +143,7 @@ module Parfait
|
|
142
143
|
page = @pages[requested_name]
|
143
144
|
if page
|
144
145
|
# Confirm that we are in the requested application
|
145
|
-
|
146
|
-
raise "Cannot navigate to page \"#{requested_name}\" because application presence check failed" unless present()
|
147
|
-
end
|
146
|
+
verify_presence "Cannot navigate to page \"#{requested_name}\" because application presence check failed"
|
148
147
|
|
149
148
|
# Pass the browser through to any subsequently called methods
|
150
149
|
Thread.current[:parfait_region] = Thread.current[:parfait_browser]
|
data/lib/parfait/artifact.rb
CHANGED
@@ -22,11 +22,14 @@ module Parfait
|
|
22
22
|
#
|
23
23
|
# *Options*
|
24
24
|
#
|
25
|
-
# +
|
25
|
+
# +block+:: specifies the code block to be executed as the check method. This block should return true or false.
|
26
26
|
#
|
27
27
|
# *Example*
|
28
28
|
#
|
29
|
-
#
|
29
|
+
# sample_page.add_check {
|
30
|
+
# Parfait::browser.h1(:text => "Parfait Example Page").present?
|
31
|
+
# }
|
32
|
+
#
|
30
33
|
def add_check(&block)
|
31
34
|
@check_method = block
|
32
35
|
add_generic_present() unless @present_method
|
@@ -37,11 +40,12 @@ module Parfait
|
|
37
40
|
#
|
38
41
|
# *Options*
|
39
42
|
#
|
40
|
-
# This method
|
43
|
+
# This method takes a hash of parameters, as defined by the +check+ code block
|
41
44
|
#
|
42
45
|
# *Example*
|
43
46
|
#
|
44
|
-
#
|
47
|
+
# myapp.page("My Page").check
|
48
|
+
#
|
45
49
|
def check(opts = {})
|
46
50
|
@check_method.call(opts)
|
47
51
|
end
|
@@ -51,11 +55,16 @@ module Parfait
|
|
51
55
|
#
|
52
56
|
# *Options*
|
53
57
|
#
|
54
|
-
# +
|
58
|
+
# +block+:: specifies the code block to be executed as the present method. This block should return true or false.
|
59
|
+
#
|
60
|
+
# For consistency, it is recommended that the check method be defined with +add_check+, which will set up the present directive automatically.
|
55
61
|
#
|
56
62
|
# *Example*
|
57
63
|
#
|
58
|
-
#
|
64
|
+
# sample_page.add_present {
|
65
|
+
# Parfait::browser.h1(:text => "Parfait Example Page").present?
|
66
|
+
# }
|
67
|
+
#
|
59
68
|
def add_present(&block)
|
60
69
|
@present_method = block
|
61
70
|
end
|
@@ -65,27 +74,27 @@ module Parfait
|
|
65
74
|
#
|
66
75
|
# *Options*
|
67
76
|
#
|
68
|
-
# This method
|
77
|
+
# This method takes a hash of parameters, as defined by the +present+ code block
|
69
78
|
#
|
70
79
|
# *Example*
|
71
80
|
#
|
72
|
-
#
|
81
|
+
# myapp.page("My Page").check
|
82
|
+
#
|
73
83
|
def present(opts = {})
|
74
84
|
@present_method.call(opts)
|
75
85
|
end
|
76
86
|
|
77
87
|
|
78
|
-
#
|
79
|
-
#
|
80
|
-
# Depends on check
|
88
|
+
# Define the secondary +present+ directive based on the user-defined primary +check+ directive
|
81
89
|
#
|
82
90
|
# *Options*
|
83
91
|
#
|
84
|
-
#
|
92
|
+
# None
|
85
93
|
#
|
86
94
|
# *Example*
|
87
95
|
#
|
88
|
-
#
|
96
|
+
# No example provided - this will be called under the covers when a +check+ directive is defined
|
97
|
+
#
|
89
98
|
def add_generic_present()
|
90
99
|
add_present { |opts|
|
91
100
|
check(opts)
|
@@ -95,15 +104,14 @@ module Parfait
|
|
95
104
|
|
96
105
|
# Is the present method defined for this Artifact?
|
97
106
|
#
|
98
|
-
# Depends on check
|
99
|
-
#
|
100
107
|
# *Options*
|
101
108
|
#
|
102
109
|
# This method takes no parameters
|
103
110
|
#
|
104
111
|
# *Example*
|
105
112
|
#
|
106
|
-
#
|
113
|
+
# myapp.page("My Page").is_present_defined?
|
114
|
+
#
|
107
115
|
def is_present_defined?()
|
108
116
|
if @present_method
|
109
117
|
return true
|
@@ -112,6 +120,31 @@ module Parfait
|
|
112
120
|
end
|
113
121
|
end
|
114
122
|
|
123
|
+
|
124
|
+
# Verify the presence of this Artifact
|
125
|
+
#
|
126
|
+
# Raises an exception with the specified check if this artifact is not present
|
127
|
+
#
|
128
|
+
# *Options*
|
129
|
+
#
|
130
|
+
# +error_string+:: specifies the string to display if the check fails
|
131
|
+
#
|
132
|
+
# *Example*
|
133
|
+
#
|
134
|
+
# class Control
|
135
|
+
# def get(opts = {})
|
136
|
+
# verify_presence "Cannot call get directive because presence check for control \"#{@name}\" failed"
|
137
|
+
# return @get_method.call(opts)
|
138
|
+
# end
|
139
|
+
# end
|
140
|
+
def verify_presence(error_string)
|
141
|
+
if is_present_defined?
|
142
|
+
unless present()
|
143
|
+
raise error_string
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
115
148
|
end
|
116
149
|
end
|
117
150
|
|
data/lib/parfait/control.rb
CHANGED
@@ -60,6 +60,7 @@ module Parfait
|
|
60
60
|
raise "Parfait::Control requires each alias in the array to be a string" unless my_alias.is_a?(String)
|
61
61
|
end
|
62
62
|
end
|
63
|
+
super
|
63
64
|
end
|
64
65
|
|
65
66
|
|
@@ -139,9 +140,7 @@ module Parfait
|
|
139
140
|
#
|
140
141
|
# $$$ Need an example $$$
|
141
142
|
def verify_control_presence(directive_name)
|
142
|
-
|
143
|
-
raise "Cannot call \"#{directive_name}\" directive because presence check for control \"#{@name}\" failed" unless present()
|
144
|
-
end
|
143
|
+
verify_presence "Cannot call \"#{directive_name}\" directive because presence check for control \"#{@name}\" failed"
|
145
144
|
end
|
146
145
|
|
147
146
|
|
data/lib/parfait/page.rb
CHANGED
@@ -40,6 +40,7 @@ module Parfait
|
|
40
40
|
@controls = Hash.new
|
41
41
|
@regions = Hash.new
|
42
42
|
@page_test = nil
|
43
|
+
super
|
43
44
|
end
|
44
45
|
|
45
46
|
|
@@ -132,9 +133,7 @@ module Parfait
|
|
132
133
|
if region
|
133
134
|
|
134
135
|
# Confirm that we are on the expected page
|
135
|
-
|
136
|
-
raise "Cannot navigate to region \"#{opts.first[0]}\" because page presence check failed" unless present()
|
137
|
-
end
|
136
|
+
verify_presence "Cannot navigate to region \"#{opts.first[0]}\" because page presence check failed"
|
138
137
|
|
139
138
|
# Apply the filter method
|
140
139
|
region.filter(opts.first[1])
|
@@ -258,9 +257,7 @@ module Parfait
|
|
258
257
|
if control
|
259
258
|
|
260
259
|
# Confirm that we are on the expected page
|
261
|
-
|
262
|
-
raise "Cannot navigate to control \"#{requested_name}\" because page presence check failed" unless present()
|
263
|
-
end
|
260
|
+
verify_presence "Cannot navigate to control \"#{requested_name}\" because page presence check failed"
|
264
261
|
|
265
262
|
return control
|
266
263
|
else
|
data/lib/parfait/region.rb
CHANGED
@@ -43,7 +43,7 @@ module Parfait
|
|
43
43
|
# )
|
44
44
|
#
|
45
45
|
def initialize(opts = {})
|
46
|
-
|
46
|
+
o = {
|
47
47
|
:name => nil,
|
48
48
|
:aliases => []
|
49
49
|
}.merge(opts)
|
@@ -68,6 +68,7 @@ module Parfait
|
|
68
68
|
raise "Parfait::Region requires each alias in the array to be a string" unless my_alias.is_a?(String)
|
69
69
|
end
|
70
70
|
end
|
71
|
+
super
|
71
72
|
end
|
72
73
|
|
73
74
|
|
@@ -251,9 +252,7 @@ module Parfait
|
|
251
252
|
if region
|
252
253
|
|
253
254
|
# Confirm that we are in the expected region
|
254
|
-
|
255
|
-
raise "Cannot navigate to region \"#{opts.first[0]}\" because region presence check failed" unless present()
|
256
|
-
end
|
255
|
+
verify_presence "Cannot navigate to region \"#{opts.first[0]}\" because region presence check failed"
|
257
256
|
|
258
257
|
# Apply the filter method
|
259
258
|
region.filter(opts.first[1])
|
@@ -319,9 +318,7 @@ module Parfait
|
|
319
318
|
control = @controls[requested_name]
|
320
319
|
if control
|
321
320
|
# Confirm that we are in the expected region
|
322
|
-
|
323
|
-
raise "Cannot navigate to control \"#{requested_name}\" because region presence check failed" unless present()
|
324
|
-
end
|
321
|
+
verify_presence "Cannot navigate to control \"#{requested_name}\" because region presence check failed"
|
325
322
|
|
326
323
|
|
327
324
|
return control
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: parfait
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.11.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeremy Rotter
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-08-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|