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 CHANGED
@@ -1,3 +1,6 @@
1
+ 2.1.0
2
+ Added Wait utility class.
3
+
1
4
  2.0.1
2
5
  Fixed issue with no_proxy variable not being honoured (Mechanize driver).
3
6
 
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- frameworks-capybara (2.0.1)
4
+ frameworks-capybara (2.1.0)
5
5
  capybara
6
6
  capybara-mechanize
7
7
  cucumber
@@ -1,4 +1,5 @@
1
1
  require 'frameworks/cucumber'
2
2
  require 'frameworks/capybara'
3
+ require 'frameworks/wait'
3
4
 
4
5
  CapybaraSetup.new unless ENV['CAPYBARA_DISABLED']
@@ -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
@@ -1,3 +1,3 @@
1
1
  module FrameworksCapybara
2
- VERSION = '2.0.1'
2
+ VERSION = '2.1.0'
3
3
  end
@@ -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.1
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-17 00:00:00.000000000 Z
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: 3489083016485421328
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: 3489083016485421328
214
+ hash: -2516122325611902665
213
215
  requirements: []
214
216
  rubyforge_project:
215
217
  rubygems_version: 1.8.23.2