Sha256: 56eb95d06247f3d09d364caf61b5a555776d2fac9699ad98513464b71d127fc8

Contents?: true

Size: 1.16 KB

Versions: 14

Compression:

Stored size: 1.16 KB

Contents

module TestCollection
  # Anything that includes TestCollection must, during setup, assign @subject and @factory, where
  #   @subject is the collection under test, (e.g. Fog::Compute[:google].servers)
  #   @factory is a CollectionFactory

  def test_lifecycle
    one = @subject.new(@factory.params)
    one.save
    two = @subject.create(@factory.params)

    # XXX HACK compares identities
    # should be replaced with simple includes? when `==` is properly implemented in fog-core; see fog/fog-core#148
    assert_includes @subject.all.map(&:identity), one.identity
    assert_includes @subject.all.map(&:identity), two.identity

    assert_equal one.identity, @subject.get(one.identity).identity
    assert_equal two.identity, @subject.get(two.identity).identity

    one.destroy
    two.destroy

    Fog.wait_for { !@subject.all.map(&:identity).include? one.identity }
    Fog.wait_for { !@subject.all.map(&:identity).include? two.identity }
  end

  def test_get_returns_nil_if_resource_does_not_exist
    assert_nil @subject.get("fog-test-fake-identity")
  end

  def test_enumerable
    assert_respond_to @subject, :each
  end

  def teardown
    @factory.cleanup
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
fog-google-0.6.0 test/helpers/test_collection.rb
fog-google-0.5.5 test/helpers/test_collection.rb
fog-google-0.5.4 test/helpers/test_collection.rb
fog-google-0.5.3 test/helpers/test_collection.rb
fog-google-0.5.2 test/helpers/test_collection.rb
fog-google-0.5.1 test/helpers/test_collection.rb
fog-google-0.5.0 test/helpers/test_collection.rb
fog-google-0.4.2 test/helpers/test_collection.rb
fog-google-0.4.1 test/helpers/test_collection.rb
fog-google-0.4.0 test/helpers/test_collection.rb
fog-google-0.3.2 test/helpers/test_collection.rb
fog-google-0.3.1 test/helpers/test_collection.rb
fog-google-0.3.0 test/helpers/test_collection.rb
fog-google-0.2.0 test/helpers/test_collection.rb