wist 0.0.10 → 0.0.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/wist.rb +18 -4
- data/test/tests/wist_test.rb +11 -0
- data/wist.gemspec +1 -1
- 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: 3162aed8a3a36b5b573e05df2fe44d005ca6f774
|
4
|
+
data.tar.gz: 8f2aef2f8836366921319dda68f56c3eaf40f007
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9fee6d1d974c47eec0881ffc23472fd1053e1052b0a4ae5280676acdb7570028928ecd1ea93f329bbdc1ecde9e581103c6968449127b7a6943805ecd1dd9f781
|
7
|
+
data.tar.gz: 747093992700efac2d1dbd4bb1406619d096f9719bfe126edfb6eabe162b54a7f0cd011902fa7ac5f81f85a6f7231f71040cc6bb93bf8764aeceae75fe33739d
|
data/Gemfile.lock
CHANGED
data/lib/wist.rb
CHANGED
@@ -8,10 +8,10 @@ module Wist
|
|
8
8
|
end
|
9
9
|
|
10
10
|
module Helpers
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
11
|
+
module_function
|
12
|
+
|
13
|
+
def blank?(obj)
|
14
|
+
obj.respond_to?(:empty?) ? obj.empty? : !obj
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
@@ -118,4 +118,18 @@ module Wist
|
|
118
118
|
page.send(finder.to_sym, selector)
|
119
119
|
end
|
120
120
|
end
|
121
|
+
|
122
|
+
def visit_with_retries(url, retries: 5, wait_time: 10)
|
123
|
+
raise 'only works with poltergeist' unless Capybara.javascript_driver == :poltergeist
|
124
|
+
status = nil
|
125
|
+
|
126
|
+
retries.times do |i|
|
127
|
+
status = visit(url)['status']
|
128
|
+
break if status == 'success'
|
129
|
+
puts "visiting #{url} failed, attempting retry #{i + 1}/#{retries} in #{wait_time} second(s)"
|
130
|
+
sleep wait_time
|
131
|
+
end
|
132
|
+
|
133
|
+
raise "visit #{url} failed" unless status == 'success'
|
134
|
+
end
|
121
135
|
end
|
data/test/tests/wist_test.rb
CHANGED
@@ -119,4 +119,15 @@ class WistTest < CapybaraTestCase
|
|
119
119
|
click('#finder_with_wait')
|
120
120
|
assert_equal('finder_with_wait', all_with_wait('.done')[0][:id])
|
121
121
|
end
|
122
|
+
|
123
|
+
def test_visit_with_retries
|
124
|
+
return unless Capybara.javascript_driver == :poltergeist
|
125
|
+
|
126
|
+
assert_raise RuntimeError do
|
127
|
+
visit_with_retries('a.bc', retries: 2, wait_time: 1)
|
128
|
+
end
|
129
|
+
|
130
|
+
visit_with_retries("file://#{Dir.pwd}/test/test0.html")
|
131
|
+
verify_test_page(0)
|
132
|
+
end
|
122
133
|
end
|
data/wist.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wist
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lihan Li
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-04-
|
11
|
+
date: 2013-04-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: capybara
|