Sha256: 57087f4066bd6758b9da47ab10474ce44830696d0c2cc295f77da69bbd3016d6

Contents?: true

Size: 1.62 KB

Versions: 69

Compression:

Stored size: 1.62 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.send(:convert_vm_mob_ref_to_attr_hash, fake_vm_mob_ref).kind_of? Hash
      end
      tests("The converted Hash should") do
        attr_hash = compute.send(: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.send :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

69 entries across 69 versions & 8 rubygems

Version Path
fog-maestrodev-1.15.0.20130927082724 tests/vsphere/compute_tests.rb
fog-maestrodev-1.15.0.20130829165835 tests/vsphere/compute_tests.rb
fog-1.15.0 tests/vsphere/compute_tests.rb
gapinc-fog-1.14.0 tests/vsphere/compute_tests.rb
fog-maestrodev-1.14.0.20130806165225 tests/vsphere/compute_tests.rb
fog-1.14.0 tests/vsphere/compute_tests.rb
fog-1.13.0 tests/vsphere/compute_tests.rb
gapinc-fog-1.12.1.2 tests/vsphere/compute_tests.rb
gapinc-fog-1.12.1.1 tests/vsphere/compute_tests.rb
gapinc-fog-1.12.1a tests/vsphere/compute_tests.rb
gapinc-fog-1.12.1 tests/vsphere/compute_tests.rb
fog-1.12.1 tests/vsphere/compute_tests.rb
fog-1.12.0 tests/vsphere/compute_tests.rb
hpfog-0.0.20 tests/vsphere/compute_tests.rb
vagrant-shell-0.2.6 vendor/bundle/gems/fog-1.10.1/tests/vsphere/compute_tests.rb
vagrant-shell-0.2.5 vendor/bundle/gems/fog-1.10.1/tests/vsphere/compute_tests.rb
fog-nirvanix-1.8.2 tests/vsphere/compute_tests.rb
fog-1.11.1 tests/vsphere/compute_tests.rb
fog-1.11.0 tests/vsphere/compute_tests.rb
fog-nirvanix-1.8.1 tests/vsphere/compute_tests.rb