Sha256: 19793b95047975de83e612ce1edcbe20fd26e67205fc0b9ac8dd74ca0eb565b3

Contents?: true

Size: 923 Bytes

Versions: 54

Compression:

Stored size: 923 Bytes

Contents

#
# Author:: Matt Eldridge (<matt.eldridge@us.ibm.com>)
# © Copyright IBM Corporation 2014.
#
# LICENSE: MIT (http://opensource.org/licenses/MIT)
#

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

  tests('success') do

    @instance = collection.new(params)

    tests("#save").succeeds do
      pending if Fog.mocking? && !mocks_implemented
      @instance.save
    end

    if block_given?
      yield
    end

    tests("#destroy").succeeds do
      pending if Fog.mocking? && !mocks_implemented
      @instance.destroy
    end

  end

end

# Generates a unique identifier with a random differentiator.
# Useful when rapidly re-running tests, so we don't have to wait
# serveral minutes for deleted objects to disappear from the API
# E.g. 'fog-test-1234'
def uniq_id(base_name = 'fog-test')
  # random_differentiator
  suffix = rand(65536).to_s(16).rjust(4, '0')
  [base_name, suffix] * '-'
end


Version data entries

54 entries across 52 versions & 3 rubygems

Version Path
fog-softlayer-0.4.1 tests/helpers/model_helper.rb
fog-softlayer-0.4.0 tests/helpers/model_helper.rb
fog-softlayer-0.3.30 tests/helpers/model_helper.rb
fog-softlayer-0.3.29 tests/helpers/model_helper.rb
fog-softlayer-0.3.28 tests/helpers/model_helper.rb
fog-softlayer-0.3.27 tests/helpers/model_helper.rb
fog-softlayer-0.3.26 tests/helpers/model_helper.rb
fog-softlayer-0.3.25 tests/helpers/model_helper.rb
fog-softlayer-0.3.24 tests/helpers/model_helper.rb
fog-softlayer-0.3.23 tests/helpers/model_helper.rb
fog-softlayer-0.3.22 tests/helpers/model_helper.rb
fog-softlayer-0.3.21 tests/helpers/model_helper.rb
fog-softlayer-0.3.20 tests/helpers/model_helper.rb
fog-softlayer-0.3.19 tests/helpers/model_helper.rb
fog-softlayer-0.3.18 tests/helpers/model_helper.rb
fog-softlayer-0.3.17 tests/helpers/model_helper.rb
fog-softlayer-0.3.16 tests/helpers/model_helper.rb
fog-softlayer-0.3.15 tests/helpers/model_helper.rb
fog-softlayer-0.3.14 tests/helpers/model_helper.rb
fog-softlayer-0.3.13 tests/helpers/model_helper.rb