Sha256: 4e3f9ff14f36d48f80f56a8ce447de5d02be50da734a3509564fd234d03cf51c

Contents?: true

Size: 1.42 KB

Versions: 42

Compression:

Stored size: 1.42 KB

Contents

def collection_tests(collection, params = {}, mocks_implemented = true)

  tests('success') do

    tests("#new(#{params.inspect})").succeeds do
      pending if Fog.mocking? && !mocks_implemented
      collection.new(params)
    end

    tests("#create(#{params.inspect})").succeeds do
      pending if Fog.mocking? && !mocks_implemented
      @instance = collection.create(params)
    end

    # FIXME: work around for timing issue on AWS describe_instances mocks
    if Fog.mocking? && @instance.respond_to?(:ready?)
      @instance.wait_for { ready? }
    end

    tests("#all").succeeds do
      pending if Fog.mocking? && !mocks_implemented
      collection.all
    end

    if !Fog.mocking? || mocks_implemented
      @identity = @instance.identity
    end

    tests("#get(#{@identity})").succeeds do
      pending if Fog.mocking? && !mocks_implemented
      collection.get(@identity)
    end

    if block_given?
      yield
    end

    if !Fog.mocking? || mocks_implemented
      @instance.destroy
    end
  end

  tests('failure') do

    if !Fog.mocking? || mocks_implemented
      @identity = @identity.to_s
      @identity = @identity.gsub(/[a-zA-Z]/) { Fog::Mock.random_letters(1) }
      @identity = @identity.gsub(/\d/)       { Fog::Mock.random_numbers(1) }
      @identity
    end

    tests("#get('#{@identity}')").returns(nil) do
      pending if Fog.mocking? && !mocks_implemented
      collection.get(@identity)
    end

  end

end

Version data entries

42 entries across 42 versions & 14 rubygems

Version Path
michiels-fog-1.3.1 tests/helpers/collection_helper.rb
ftl-0.2.0 vendor/bundle/gems/fog-1.3.1/tests/helpers/collection_helper.rb
brightbox-cli-0.18.0 lib/brightbox-cli/vendor/fog/tests/helpers/collection_helper.rb
fog-1.3.1 tests/helpers/collection_helper.rb
fog-1.3.0 tests/helpers/collection_helper.rb
brightbox-cli-0.17.5 lib/brightbox-cli/vendor/fog/tests/helpers/collection_helper.rb
fog-1.2.0 tests/helpers/collection_helper.rb
ktheory-fog-1.1.2 tests/helpers/collection_helper.rb
brightbox-cli-0.17.4 lib/brightbox-cli/vendor/fog/tests/helpers/collection_helper.rb
brightbox-cli-0.17.3 lib/brightbox-cli/vendor/fog/tests/helpers/collection_helper.rb
brightbox-cli-0.17.2 lib/brightbox-cli/vendor/fog/tests/helpers/collection_helper.rb
brightbox-cli-0.17.1 lib/brightbox-cli/vendor/fog/tests/helpers/collection_helper.rb
brightbox-cli-0.17.0 lib/brightbox-cli/vendor/fog/tests/helpers/collection_helper.rb
fog-1.1.2 tests/helpers/collection_helper.rb
fog_tractical-1.1.4 tests/helpers/collection_helper.rb
fog_tractical-1.1.3 tests/helpers/collection_helper.rb
brightbox-cli-0.16.0 lib/brightbox-cli/vendor/fog/tests/helpers/collection_helper.rb
fog-1.1.1 tests/helpers/collection_helper.rb
fog-1.1.0 tests/helpers/collection_helper.rb
brightbox-cli-0.15.0 lib/brightbox-cli/vendor/fog/tests/helpers/collection_helper.rb