Sha256: 430292504ae659ef6847ebe2511dd73275db24a22310939dbd705c2f4adcc637

Contents?: true

Size: 1.1 KB

Versions: 34

Compression:

Stored size: 1.1 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

    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.gsub(/\w/, '0')
    end

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

  end

end

Version data entries

34 entries across 34 versions & 2 rubygems

Version Path
fog-0.3.31 tests/helpers/collection_tests.rb
fog-0.3.30 tests/helpers/collection_tests.rb
fog-0.3.29 tests/helpers/collection_tests.rb
fog-0.3.28 tests/helpers/collection_tests.rb
fog-0.3.27 tests/helpers/collection_tests.rb
fog-0.3.26 tests/helpers/collection_tests.rb
fog-0.3.25 tests/helpers/collection_tests.rb
fog-0.3.24 tests/helpers/collection_tests.rb
fog-0.3.23 tests/helpers/collection_tests.rb
fog-0.3.22 tests/helpers/collection_tests.rb
fog-0.3.21 tests/helpers/collection_tests.rb
fog-0.3.20 tests/helpers/collection_tests.rb
fog-0.3.19 tests/helpers/collection_tests.rb
fog-0.3.18 tests/helpers/collection_tests.rb