Sha256: bc7a3c7f590a782b6d973a9f0b9cedfdba9b2d76bc0d4f40c14cd1e766553964

Contents?: true

Size: 761 Bytes

Versions: 38

Compression:

Stored size: 761 Bytes

Contents

require "spec_helper"

describe "Fog#wait_for" do
  it "returns a Hash indicating the wait duration if successful" do
    assert_equal({ :duration => 0 }, Fog.wait_for(1) { true })
  end

  it "raises if the wait timeout is exceeded" do
    assert_raises(Fog::Errors::TimeoutError) do
      Fog.wait_for(2) { false }
    end
  end

  it "does not raise if successful when the wait timeout is exceeded" do
    timeout = 2
    i = 0
    ret = Fog.wait_for(timeout) { i = i + 1; i > 2 }
    assert_operator(ret[:duration], :>, timeout)
  end

  it "accepts a proc to determine the sleep interval" do
    i = 0
    ret = Fog.wait_for(1, lambda { |_t| 1 }) do
      i += 1
      i > 1
    end
    assert(1 <= ret[:duration])
    assert(ret[:duration] < 2)
  end
end

Version data entries

38 entries across 35 versions & 3 rubygems

Version Path
fog-core-2.3.0 spec/wait_for_spec.rb
fog-core-2.2.4 spec/wait_for_spec.rb
fog-core-2.2.3 spec/wait_for_spec.rb
fog-core-2.2.2 spec/wait_for_spec.rb
fog-core-2.2.1 spec/wait_for_spec.rb
fog-core-2.2.0 spec/wait_for_spec.rb
fog-core-2.1.2 spec/wait_for_spec.rb
fog-core-2.1.1 spec/wait_for_spec.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.3.0/gems/fog-core-1.45.0/spec/wait_for_spec.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.4.0/gems/fog-core-1.45.0/spec/wait_for_spec.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.4.0/gems/fog-core-2.1.0/spec/wait_for_spec.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.5.0/gems/fog-core-1.45.0/spec/wait_for_spec.rb
fog-core-2.1.0 spec/wait_for_spec.rb
fog-core-2.0.0 spec/wait_for_spec.rb
fog-core-1.45.0 spec/wait_for_spec.rb
fog-core-1.44.3 spec/wait_for_spec.rb
fog-core-1.44.2 spec/wait_for_spec.rb
fog-core-1.44.1 spec/wait_for_spec.rb
fog-core-1.44.0 spec/wait_for_spec.rb
fog-core-1.43.0 spec/wait_for_spec.rb