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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8fb3874a0cbd27521015a51123dc37912ae7708c
4
- data.tar.gz: 99902dd96ce73b941af89b66a43675caf366f175
3
+ metadata.gz: 3162aed8a3a36b5b573e05df2fe44d005ca6f774
4
+ data.tar.gz: 8f2aef2f8836366921319dda68f56c3eaf40f007
5
5
  SHA512:
6
- metadata.gz: 8d867e7fe59d795a3ee457b7aa71194d64aeb257275b0b0087fab4667b60a401a237ae9ff48cef7058ab3d7e8b6a630aa875e8a74642dea24098442bf48ff0a5
7
- data.tar.gz: d00a40b29a4b8a0fd99efd4420dbc3ba004c8b9797673aadfb85d71e5eb1a933684d563c778d5adc9faf53e8ac219fc6c07dcb39c810fdb47deac42c73caae92
6
+ metadata.gz: 9fee6d1d974c47eec0881ffc23472fd1053e1052b0a4ae5280676acdb7570028928ecd1ea93f329bbdc1ecde9e581103c6968449127b7a6943805ecd1dd9f781
7
+ data.tar.gz: 747093992700efac2d1dbd4bb1406619d096f9719bfe126edfb6eabe162b54a7f0cd011902fa7ac5f81f85a6f7231f71040cc6bb93bf8764aeceae75fe33739d
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- wist (0.0.10)
4
+ wist (0.0.11)
5
5
  capybara
6
6
 
7
7
  GEM
data/lib/wist.rb CHANGED
@@ -8,10 +8,10 @@ module Wist
8
8
  end
9
9
 
10
10
  module Helpers
11
- class << self
12
- def blank?(obj)
13
- obj.respond_to?(:empty?) ? obj.empty? : !obj
14
- end
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
@@ -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
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |gem|
2
2
  gem.name = 'wist'
3
- gem.version = '0.0.10'
3
+ gem.version = '0.0.11'
4
4
  gem.summary = 'capybara helpers'
5
5
  gem.author = 'Lihan Li'
6
6
  gem.email = 'frankieteardrop@gmail.com'
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.10
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-12 00:00:00.000000000 Z
11
+ date: 2013-04-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: capybara