Sha256: b610dfa9b26b87f94e06029a1cab3dd9c7bb8e125ab5a246886dba693c5ff6a2

Contents?: true

Size: 755 Bytes

Versions: 1

Compression:

Stored size: 755 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 += 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

1 entries across 1 versions & 1 rubygems

Version Path
fog-core-2.4.0 spec/wait_for_spec.rb