wist 0.1.6 → 0.2.0

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: b6150ba5406034ca7dede15c09f857706842af71
4
- data.tar.gz: e56f65705c2f4b1b02c794fcc1b9430e145c70aa
3
+ metadata.gz: 0cc764cb16ae3e69fbd83e69683b71f3376624ef
4
+ data.tar.gz: e3cec4ee9c95beca47ff8998ed9d711deb2820c2
5
5
  SHA512:
6
- metadata.gz: 7044443c1ce69637a1e89669076fc480251bcca91d781ac6d853b7dfdebb93389eacc89407d5070f43e3f57aa8d6c1a8015e9dbe747b6363ba06428a33b5c3e2
7
- data.tar.gz: ced3cb4464579bc5a8be74f527a6f42e904fb29cb32ac3a20b09e817a156b2c1dfd9100dd586862e2c494600a483aee8246d96d6b8508297a32db5c893b14aaf
6
+ metadata.gz: 1c2162229c88a9cc9edf5258fbf7393066e9ec6bb5a1e8bf9c5503251d27687aab33dda8acda3dff39e5332380763f9bfc75fc21a00e42aeb00757132e16b48b
7
+ data.tar.gz: 5ac8dd9a14280305772a95e88f6388564857f5551a2cbf20b791ec07246abfeae35c030cb8050a7afc2f9b1734abe9c4fbf59a76167ce657c39dbc034f566116
data/Gemfile.lock CHANGED
@@ -9,7 +9,7 @@ GIT
9
9
  PATH
10
10
  remote: .
11
11
  specs:
12
- wist (0.1.6)
12
+ wist (0.2.0)
13
13
  capybara
14
14
  selenium-webdriver
15
15
 
data/lib/wist.rb CHANGED
@@ -16,18 +16,15 @@ module Wist
16
16
  end
17
17
 
18
18
  def wait_until(timeout: Capybara.default_wait_time)
19
- old_timeout = Capybara.default_wait_time
20
- Capybara.default_wait_time = 0
21
-
22
- Selenium::WebDriver::Wait.new(timeout: timeout).until do
23
- begin
24
- yield
25
- rescue
26
- false
19
+ do_instantly do
20
+ Selenium::WebDriver::Wait.new(timeout: timeout).until do
21
+ begin
22
+ yield
23
+ rescue
24
+ false
25
+ end
27
26
  end
28
27
  end
29
-
30
- Capybara.default_wait_time = old_timeout
31
28
  end
32
29
 
33
30
  def click(selector)
@@ -170,6 +167,19 @@ module Wist
170
167
  end
171
168
 
172
169
  def has_css_instant?(selector)
173
- page.evaluate_script("$('#{selector}:visible').length > 0")
170
+ do_instantly { has_css?(selector) }
171
+ end
172
+
173
+ def do_instantly
174
+ old_time = Capybara.default_wait_time
175
+ Capybara.default_wait_time = 0
176
+
177
+ begin
178
+ yield
179
+ rescue => e
180
+ raise(e)
181
+ ensure
182
+ Capybara.default_wait_time = old_time
183
+ end
174
184
  end
175
185
  end
@@ -165,4 +165,20 @@ class WistTest < CapybaraTestCase
165
165
  assert_equal(true, has_css_instant?('body'))
166
166
  assert_equal(false, has_css_instant?('#sdklfjk'))
167
167
  end
168
+
169
+ def test_do_instantly
170
+ old_time = Capybara.default_wait_time
171
+ new_time = nil
172
+
173
+ begin
174
+ do_instantly do
175
+ new_time = Capybara.default_wait_time
176
+ raise
177
+ end
178
+ rescue
179
+ end
180
+
181
+ assert_equal(0, new_time)
182
+ assert_equal(old_time, Capybara.default_wait_time)
183
+ end
168
184
  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.1.6'
3
+ gem.version = '0.2.0'
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.1.6
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lihan Li
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-19 00:00:00.000000000 Z
11
+ date: 2014-05-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: capybara