dill 0.4.3 → 0.4.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/dill/checkpoint.rb +11 -1
- data/lib/dill/version.rb +1 -1
- data/lib/dill/widget.rb +17 -21
- metadata +2 -2
data/lib/dill/checkpoint.rb
CHANGED
@@ -16,6 +16,16 @@ module Dill
|
|
16
16
|
Capybara.current_session.driver
|
17
17
|
end
|
18
18
|
|
19
|
+
# Executes +block+ repeatedly until it returns a "truthy" value or +timeout+
|
20
|
+
# expires.
|
21
|
+
#
|
22
|
+
# TODO: Expand documentation.
|
23
|
+
def self.wait_for(wait_time = Capybara.default_wait_time,
|
24
|
+
raise_errors = true,
|
25
|
+
&block)
|
26
|
+
new(wait_time).wait_for(raise_errors, &block)
|
27
|
+
end
|
28
|
+
|
19
29
|
# Initializes a new Checkpoint.
|
20
30
|
#
|
21
31
|
# @param wait_time how long this checkpoint will wait for its conditions to
|
@@ -48,7 +58,7 @@ module Dill
|
|
48
58
|
# @return whatever the condition block returns if the condition is
|
49
59
|
# successful. If the condition is not met, returns +false+ if
|
50
60
|
# +rescue_errors+ is false.
|
51
|
-
def
|
61
|
+
def wait_for(raise_errors = true, &condition)
|
52
62
|
start
|
53
63
|
|
54
64
|
begin
|
data/lib/dill/version.rb
CHANGED
data/lib/dill/widget.rb
CHANGED
@@ -219,27 +219,23 @@ module Dill
|
|
219
219
|
# Compares the current widget with +value+, waiting for the comparison
|
220
220
|
# to return +true+.
|
221
221
|
def ==(value)
|
222
|
-
|
222
|
+
wait_for { cast_to_type_of(value) == value }
|
223
223
|
end
|
224
224
|
|
225
225
|
# Calls +=~+ on this widget's text content.
|
226
226
|
def =~(regexp)
|
227
|
-
|
227
|
+
wait_for { to_s =~ regexp }
|
228
228
|
end
|
229
229
|
|
230
230
|
# Calls +!~+ on this widget's text content.
|
231
231
|
def !~(regexp)
|
232
|
-
|
232
|
+
wait_for { to_s !~ regexp }
|
233
233
|
end
|
234
234
|
|
235
235
|
# Compares the current widget with +value+, waiting for the comparison
|
236
236
|
# to return +false+.
|
237
237
|
def !=(value)
|
238
|
-
|
239
|
-
end
|
240
|
-
|
241
|
-
def checkpoint(wait_time)
|
242
|
-
Checkpoint.new(wait_time)
|
238
|
+
wait_for { cast_to_type_of(value) != value }
|
243
239
|
end
|
244
240
|
|
245
241
|
# Determines if the widget underlying an action exists.
|
@@ -257,14 +253,16 @@ module Dill
|
|
257
253
|
end
|
258
254
|
|
259
255
|
def inspect
|
260
|
-
|
256
|
+
inspection = "<!-- #{self.class.name}: -->\n"
|
257
|
+
root = self.root
|
261
258
|
|
262
|
-
|
259
|
+
begin
|
260
|
+
xml = Nokogiri::HTML(page.body).at(root.path).to_xml
|
263
261
|
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
262
|
+
inspection << Nokogiri::XML(xml, &:noblanks).to_xhtml
|
263
|
+
rescue Capybara::NotSupportedByDriverError
|
264
|
+
inspection << "<#{root.tag_name}>\n#{to_s}"
|
265
|
+
end
|
268
266
|
end
|
269
267
|
|
270
268
|
class Reload < Capybara::ElementNotFound; end
|
@@ -297,7 +295,7 @@ module Dill
|
|
297
295
|
test = ->{ old_root != root }
|
298
296
|
end
|
299
297
|
|
300
|
-
|
298
|
+
wait_for(wait_time, false, &test)
|
301
299
|
|
302
300
|
begin
|
303
301
|
root.inspect
|
@@ -319,7 +317,7 @@ module Dill
|
|
319
317
|
#
|
320
318
|
# @return [MatchData] the match data from running +match+ on the text.
|
321
319
|
def match(pattern, position = 0, &block)
|
322
|
-
|
320
|
+
wait_for { to_s.match(pattern, position, &block) }
|
323
321
|
end
|
324
322
|
|
325
323
|
def to_i
|
@@ -334,11 +332,9 @@ module Dill
|
|
334
332
|
node_text(root)
|
335
333
|
end
|
336
334
|
|
337
|
-
alias_method :w, :widget
|
338
|
-
|
339
335
|
protected
|
340
336
|
|
341
|
-
def
|
337
|
+
def cast_to_type_of(value)
|
342
338
|
case value
|
343
339
|
when Float
|
344
340
|
to_f
|
@@ -359,8 +355,8 @@ module Dill
|
|
359
355
|
|
360
356
|
attr_writer :root
|
361
357
|
|
362
|
-
def
|
363
|
-
Checkpoint.
|
358
|
+
def wait_for(wait_time = Capybara.default_wait_time, raise_errors = false, &block)
|
359
|
+
Checkpoint.wait_for(wait_time, raise_errors, &block)
|
364
360
|
end
|
365
361
|
|
366
362
|
def page
|
metadata
CHANGED
@@ -2,14 +2,14 @@
|
|
2
2
|
name: dill
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.4.
|
5
|
+
version: 0.4.4
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- David Leal
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-08-
|
12
|
+
date: 2013-08-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
version_requirements: !ruby/object:Gem::Requirement
|