watir-timecop 0.1.0 → 0.1.1
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/watir-timecop/timer.rb +24 -20
- data/lib/watir-timecop/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f51d046b43b49759cab309154bcd5056de9d13de
|
4
|
+
data.tar.gz: c14f6eaffb718bb9c1af4537b3661bc82071fb99
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c48563bb74db297b4d8c40c96946803e5e06a23b2c296ee83d20133bc59b9b2e6a14edbada5f7c5f7f9e3787dd5366a2f81dfca002da8b918cce1ed0684c94c1
|
7
|
+
data.tar.gz: 8b1c242ea78a4ba3803c005825c80c4ccb19c200bd576ba1babe52efb7c0e99970c51e679d0c32f80829d76a42a086ef4cc03b192a7a6a4f3c171ae8775651bb
|
data/lib/watir-timecop/timer.rb
CHANGED
@@ -1,25 +1,29 @@
|
|
1
1
|
require 'timeout'
|
2
2
|
|
3
|
-
|
3
|
+
module Watir
|
4
|
+
module Timecop
|
5
|
+
class Timer
|
4
6
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
7
|
+
#
|
8
|
+
# Executes given block until it returns true or exceeds timeout.
|
9
|
+
# It is different from default Watir::Wait::Timer implementation
|
10
|
+
# since we use `Timeout.timeour` rather than `Time.now` to determine if
|
11
|
+
# waiting has exceeded timeout. Usage of `Time.now` is not compatible
|
12
|
+
# with Timecop gem - we may never exceed the timeout if it's stubbed.
|
13
|
+
#
|
14
|
+
# @param [Fixnum] timeout
|
15
|
+
# @yield block
|
16
|
+
# @api private
|
17
|
+
#
|
16
18
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
19
|
+
def wait(timeout, &block)
|
20
|
+
Timeout.timeout(timeout) do
|
21
|
+
(timeout / Watir::Wait::INTERVAL).to_i.times(&block)
|
22
|
+
end
|
23
|
+
rescue Timeout::Error
|
24
|
+
false
|
25
|
+
end
|
24
26
|
|
25
|
-
end #
|
27
|
+
end # Timer
|
28
|
+
end # Timecop
|
29
|
+
end # Watir
|