Sha256: b3ffe0ecb7e78af07fc47a0f237eed27c0b5db07922c6cb9dbf04907c142b1b9

Contents?: true

Size: 1.6 KB

Versions: 28

Compression:

Stored size: 1.6 KB

Contents

Shindo.tests('Fog::Compute[:vsphere]', ['vsphere']) do

  compute = Fog::Compute[:vsphere]

  tests("| convert_vm_mob_ref_to_attr_hash") do
    # Mock the RbVmomi::VIM::ManagedObject class
    class MockManagedObject

      attr_reader :parent, :_ref

      def initialize
        @parent = @_ref = 'vm-123'
      end

      def collect! *pathSet
        { '_ref' => 'vm-123', 'name' => 'fakevm' }
      end
    end

    fake_vm_mob_ref = MockManagedObject.new

    tests("When converting an incomplete vm object") do
      test("it should return a Hash") do
        compute.convert_vm_mob_ref_to_attr_hash(fake_vm_mob_ref).kind_of? Hash
      end
      tests("The converted Hash should") do
        attr_hash = compute.convert_vm_mob_ref_to_attr_hash(fake_vm_mob_ref)
        test("have a name") { attr_hash['name'] == 'fakevm' }
        test("have a mo_ref") {attr_hash['mo_ref'] == 'vm-123' }
        test("have an id") { attr_hash['id'] == 'vm-123' }
        test("not have a instance_uuid") { attr_hash['instance_uuid'].nil? }
      end
    end

    tests("When passed a nil object") do
      attr_hash = compute.convert_vm_mob_ref_to_attr_hash(nil)
      test("it should return a nil object") do
        attr_hash.nil?
      end
    end
  end

  tests("Compute attributes") do
    %w{ vsphere_is_vcenter vsphere_rev vsphere_username vsphere_server }.each do |attr|
      test("it should respond to #{attr}") { compute.respond_to? attr }
    end
  end

  tests("Compute collections") do
    %w{ servers }.each do |collection|
      test("it should respond to #{collection}") { compute.respond_to? collection }
    end
  end
end

Version data entries

28 entries across 28 versions & 10 rubygems

Version Path
fog-parser-fix-1.6.1 tests/vsphere/compute_tests.rb
fog-test-again-1.6.0 tests/vsphere/compute_tests.rb
fog-parser-fix-1.6.0 tests/vsphere/compute_tests.rb
fog-maestrodev-1.7.0.20121114190951 tests/vsphere/compute_tests.rb
fog-1.7.0 tests/vsphere/compute_tests.rb
fog-1.6.0 tests/vsphere/compute_tests.rb
fog-1.5.0 tests/vsphere/compute_tests.rb
rackspace-fog-1.4.2 tests/vsphere/compute_tests.rb
fog-1.4.0 tests/vsphere/compute_tests.rb
brightbox-cli-0.18.1 lib/brightbox-cli/vendor/fog/tests/vsphere/compute_tests.rb
michiels-fog-1.3.1 tests/vsphere/compute_tests.rb
ftl-0.2.0 vendor/bundle/gems/fog-1.3.1/tests/vsphere/compute_tests.rb
brightbox-cli-0.18.0 lib/brightbox-cli/vendor/fog/tests/vsphere/compute_tests.rb
fog-1.3.1 tests/vsphere/compute_tests.rb
fog-1.3.0 tests/vsphere/compute_tests.rb
brightbox-cli-0.17.5 lib/brightbox-cli/vendor/fog/tests/vsphere/compute_tests.rb
fog-1.2.0 tests/vsphere/compute_tests.rb
ktheory-fog-1.1.2 tests/vsphere/compute_tests.rb
brightbox-cli-0.17.4 lib/brightbox-cli/vendor/fog/tests/vsphere/compute_tests.rb
brightbox-cli-0.17.3 lib/brightbox-cli/vendor/fog/tests/vsphere/compute_tests.rb