frameworks-capybara 2.0.1 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +3 -0
- data/Gemfile.lock +1 -1
- data/lib/frameworks-capybara.rb +1 -0
- data/lib/frameworks/wait.rb +25 -0
- data/lib/version.rb +1 -1
- data/spec/wait_spec.rb +27 -0
- metadata +6 -4
data/CHANGES
CHANGED
data/Gemfile.lock
CHANGED
data/lib/frameworks-capybara.rb
CHANGED
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'time'
|
2
|
+
|
3
|
+
class Wait
|
4
|
+
##
|
5
|
+
# Execute a block until it returns true.
|
6
|
+
# Optionally pass a timeout (by default 5 seconds).
|
7
|
+
#
|
8
|
+
# wait = Wait.new
|
9
|
+
# wait.until {
|
10
|
+
# (Random.rand(2) % 2)
|
11
|
+
# }
|
12
|
+
#
|
13
|
+
# wait.until(:timeout => 4) {
|
14
|
+
# (Random.rand(2) % 2)
|
15
|
+
# }
|
16
|
+
#
|
17
|
+
def Wait.until(options={:timeout => 5})
|
18
|
+
timeout = Time.new + options[:timeout].to_f
|
19
|
+
|
20
|
+
while (Time.new < timeout)
|
21
|
+
return if (yield)
|
22
|
+
end
|
23
|
+
raise 'Timeout exceeded for wait until.'
|
24
|
+
end
|
25
|
+
end
|
data/lib/version.rb
CHANGED
data/spec/wait_spec.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'frameworks/wait'
|
2
|
+
|
3
|
+
describe Wait do
|
4
|
+
it "should exit silently if the block returns true" do
|
5
|
+
Wait.until(){
|
6
|
+
true
|
7
|
+
}
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should raise an exception if the default timeout expires" do
|
11
|
+
start_time = Time.now
|
12
|
+
expect {
|
13
|
+
Wait.until(){
|
14
|
+
Time.now > (start_time + (6 * 60))
|
15
|
+
}
|
16
|
+
}.to raise_error
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should raise an exception if the specified timeout expires" do
|
20
|
+
start_time = Time.now
|
21
|
+
expect {
|
22
|
+
Wait.until(options={:timeout => 1}) do
|
23
|
+
Time.now > (start_time + (2 * 60))
|
24
|
+
end
|
25
|
+
}.to raise_error
|
26
|
+
end
|
27
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: frameworks-capybara
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0
|
4
|
+
version: 2.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-11-
|
12
|
+
date: 2014-11-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: selenium-webdriver
|
@@ -178,6 +178,7 @@ files:
|
|
178
178
|
- lib/frameworks-capybara.rb
|
179
179
|
- lib/frameworks/capybara.rb
|
180
180
|
- lib/frameworks/cucumber.rb
|
181
|
+
- lib/frameworks/wait.rb
|
181
182
|
- lib/tasks/frameworks-tasks.rb
|
182
183
|
- lib/version.rb
|
183
184
|
- spec/frameworks_capybara_spec.rb
|
@@ -186,6 +187,7 @@ files:
|
|
186
187
|
- spec/profiles.ini
|
187
188
|
- spec/spec_helper.rb
|
188
189
|
- spec/unit_test_monkeypatches.rb
|
190
|
+
- spec/wait_spec.rb
|
189
191
|
homepage:
|
190
192
|
licenses: []
|
191
193
|
post_install_message:
|
@@ -200,7 +202,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
200
202
|
version: '0'
|
201
203
|
segments:
|
202
204
|
- 0
|
203
|
-
hash:
|
205
|
+
hash: -2516122325611902665
|
204
206
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
205
207
|
none: false
|
206
208
|
requirements:
|
@@ -209,7 +211,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
209
211
|
version: '0'
|
210
212
|
segments:
|
211
213
|
- 0
|
212
|
-
hash:
|
214
|
+
hash: -2516122325611902665
|
213
215
|
requirements: []
|
214
216
|
rubyforge_project:
|
215
217
|
rubygems_version: 1.8.23.2
|