Sha256: 4279b197dcc3863a8a9f281595c3e36ec67b57b3920c69159d963b578eefd03b

Contents?: true

Size: 1.19 KB

Versions: 7

Compression:

Stored size: 1.19 KB

Contents

require "helpers/test_helper"

class UnitTestStorageXMLCollections < MiniTest::Test
  def setup
    Fog.mock!
    @client = Fog::Storage.new(provider: "google",
                               google_storage_access_key_id: "",
                               google_storage_secret_access_key: "")

    # Enumerate all descendants of Fog::Collection
    descendants = ObjectSpace.each_object(Fog::Collection.singleton_class)

    @collections = descendants.select do |d|
      d.name.match(/Fog::Storage::GoogleXML/)
    end
  end

  def teardown
    Fog.unmock!
  end

  def test_common_methods
    # This tests whether Fog::Compute::Google collections have common lifecycle methods
    @collections.each do |klass|
      obj = klass.new
      assert obj.respond_to?(:all), "#{klass} should have an .all method"
      assert obj.respond_to?(:get), "#{klass} should have a .get method"
      assert obj.respond_to?(:each), "#{klass} should behave like Enumerable"
    end
  end

  def test_collection_get_arguments
    @collections.each do |klass|
      obj = klass.new
      assert_operator(obj.method(:get).arity, :<=, 1,
                      "#{klass} should have at most 1 required parameter in get()")
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
fog-google-1.11.0 test/unit/storage/test_common_xml_collections.rb
fog-google-1.10.0 test/unit/storage/test_common_xml_collections.rb
fog-google-1.9.1 test/unit/storage/test_common_xml_collections.rb
fog-google-1.9.0 test/unit/storage/test_common_xml_collections.rb
fog-google-1.8.2 test/unit/storage/test_common_xml_collections.rb
fog-google-1.8.1 test/unit/storage/test_common_xml_collections.rb
fog-google-1.8.0 test/unit/storage/test_common_xml_collections.rb