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
vagrant-packet-0.1.1 vendor/bundle/ruby/2.4.0/gems/fog-softlayer-1.1.4/tests/helpers/model_helper.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.5.0/gems/fog-softlayer-1.1.4/tests/helpers/model_helper.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.3.0/gems/fog-softlayer-1.1.4/tests/helpers/model_helper.rb
fog-softlayer-1.1.4 tests/helpers/model_helper.rb
fog-softlayer-1.1.3 tests/helpers/model_helper.rb
fog-softlayer-1.1.2 tests/helpers/model_helper.rb
fog-softlayer-1.1.1 tests/helpers/model_helper.rb
fog-softlayer-1.1.0 tests/helpers/model_helper.rb
fog-softlayer-1.0.3 tests/helpers/model_helper.rb
fog-softlayer-1.0.2 tests/helpers/model_helper.rb
fog-softlayer-1.0.1 tests/helpers/model_helper.rb
fog-softlayer-1.0.0 tests/helpers/model_helper.rb
vagrant-cloudstack-1.2.0 vendor/bundle/gems/fog-softlayer-0.4.7/tests/helpers/model_helper.rb
fog-softlayer-0.4.7 tests/helpers/model_helper.rb
fog-softlayer-0.4.6 tests/helpers/model_helper.rb
fog-softlayer-0.4.5 tests/helpers/model_helper.rb
fog-softlayer-0.4.4 tests/helpers/model_helper.rb
fog-softlayer-0.4.3 tests/helpers/model_helper.rb
fog-softlayer-0.4.2 tests/helpers/model_helper.rb
fog-softlayer-0.4.2.pre tests/helpers/model_helper.rb