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
hpfog-0.0.20 tests/helpers/collection_helper.rb
fog-nirvanix-1.8.2 tests/helpers/collection_helper.rb
fog-nirvanix-1.8.1 tests/helpers/collection_helper.rb
fog-parser-fix-1.6.1 tests/helpers/collection_helper.rb
fog-test-again-1.6.0 tests/helpers/collection_helper.rb
fog-parser-fix-1.6.0 tests/helpers/collection_helper.rb
fog-1.10.0 tests/helpers/collection_helper.rb
fog-1.9.0 tests/helpers/collection_helper.rb
fog-maestrodev-1.8.0.20130114204828 tests/helpers/collection_helper.rb
fog-maestrodev-1.8.0.20130111070250 tests/helpers/collection_helper.rb
fog-maestrodev-1.8.0.20130109172219 tests/helpers/collection_helper.rb
fog-sgonyea-1.8.1 tests/helpers/collection_helper.rb
fog-1.8.0 tests/helpers/collection_helper.rb
fog-maestrodev-1.7.0.20121114190951 tests/helpers/collection_helper.rb
fog-1.7.0 tests/helpers/collection_helper.rb
fog-1.6.0 tests/helpers/collection_helper.rb
fog-1.5.0 tests/helpers/collection_helper.rb
rackspace-fog-1.4.2 tests/helpers/collection_helper.rb
fog-1.4.0 tests/helpers/collection_helper.rb
brightbox-cli-0.18.1 lib/brightbox-cli/vendor/fog/tests/helpers/collection_helper.rb