waitforit 0.0.1.pre1 → 0.0.1.pre2

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.1.pre1
1
+ 0.0.1.pre2
data/lib/waitforit.rb CHANGED
@@ -12,7 +12,7 @@ class Fixnum
12
12
  end
13
13
 
14
14
  def wait_until opts={}
15
- opts.merge!(:timeout_after => 2.seconds,:retry_every => 0.1.seconds)
15
+ opts = {:timeout_after => 2.seconds,:retry_every => 0.1.seconds}.merge(opts)
16
16
  start_time = Time.now
17
17
  until Time.now > start_time + opts[:timeout_after]
18
18
  return if yield == true
@@ -9,25 +9,29 @@ describe 'waitforit' do
9
9
  end
10
10
  end_time.should be < Time.now
11
11
  end
12
-
12
+
13
13
  it 'should throw an exception if when the prescribed action does not happen in time' do
14
- expect{wait_until{false}}.to raise_error RuntimeError
14
+ expect { wait_until { false } }.to raise_error RuntimeError
15
15
  end
16
-
16
+
17
17
  it 'should keep trying for a specified period' do
18
18
  start_time = Time.now
19
19
  wait_time = 1.second
20
-
21
- lambda{wait_until(:timeout_after => wait_time){false}}
22
-
23
- (start_time + wait_time).should be >= Time.now
20
+
21
+ lambda { wait_until(:timeout_after => wait_time) { false } }
22
+
23
+ (start_time + wait_time).should be >= Time.now
24
24
  end
25
-
25
+
26
26
  it 'should be possible for user to supply the retry time' do
27
27
  count = 0
28
- wait_until(:timeout_after => 2.seconds, :retry_every => 0.5.seconds) do
29
- count += 1
30
- count == 4
28
+
29
+ begin
30
+ wait_until(:timeout_after => 1.second, :retry_every => 0.5.seconds) do
31
+ count += 1
32
+ end
33
+ rescue
34
+ count.should == 2
31
35
  end
32
36
  end
33
37
  end
data/waitforit.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{waitforit}
8
- s.version = "0.0.1.pre1"
8
+ s.version = "0.0.1.pre2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["lashd"]
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: waitforit
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease: 6
5
- version: 0.0.1.pre1
5
+ version: 0.0.1.pre2
6
6
  platform: ruby
7
7
  authors:
8
8
  - lashd
@@ -78,7 +78,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
78
78
  requirements:
79
79
  - - ">="
80
80
  - !ruby/object:Gem::Version
81
- hash: -512404082193466775
81
+ hash: 2684531027166851086
82
82
  segments:
83
83
  - 0
84
84
  version: "0"