Skip to content

Commit

Permalink
Fix Resource#wait_until(max_attempts: nil)
Browse files Browse the repository at this point in the history
It now retries indefinitely, instead of defaulting to 10 attemtps.
  • Loading branch information
ktheory committed Jun 26, 2015
1 parent 1750858 commit a5c961e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion aws-sdk-resources/lib/aws-sdk-resources/resource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def initialize(*args)
def wait_until(options = {}, &block)
resource_copy = self.dup
attempts = 0
options[:max_attempts] ||= 10
options[:max_attempts] = 10 unless options.key?(:max_attempts)
options[:delay] ||= 10
options[:poller] = Proc.new do
attempts += 1
Expand Down
6 changes: 6 additions & 0 deletions aws-sdk-resources/spec/resource_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,12 @@ module Resources
expect(resource.data).to be(data)
end

it 'allows unlimited attempts' do
attempts = 0
resource.wait_until(max_attempts:nil, delay:0) { (attempts += 1) == 12 }
expect(attempts).to be(12)
end

it 'reloads until condition met' do
allow(proc).to receive(:call).and_return(false,false, true)
expect(load_operation).to receive(:call).exactly(2).times
Expand Down

0 comments on commit a5c961e

Please sign in to comment.