spec/resource_spec.rb in vmware-vra-1.4.0 vs spec/resource_spec.rb in vmware-vra-1.5.0

- old
+ new

@@ -121,11 +121,31 @@ expect(resource.status).to eq 'ACTIVE' end end describe '#vm?' do - it 'returns true for the VM resource we created' do - expect(resource.vm?).to be true + context 'when the resource type is Infrastructure.Virtual' do + let(:resource_data) { { 'resourceTypeRef' => { 'id' => 'Infrastructure.Virtual' } } } + it 'returns true' do + allow(resource).to receive(:resource_data).and_return(resource_data) + expect(resource.vm?).to eq(true) + end + end + + context 'when the resource type is Infrastructure.Cloud' do + let(:resource_data) { { 'resourceTypeRef' => { 'id' => 'Infrastructure.Cloud' } } } + it 'returns true' do + allow(resource).to receive(:resource_data).and_return(resource_data) + expect(resource.vm?).to eq(true) + end + end + + context 'when the resource type is an unknown type' do + let(:resource_data) { { 'resourceTypeRef' => { 'id' => 'Infrastructure.Unknown' } } } + it 'returns false' do + allow(resource).to receive(:resource_data).and_return(resource_data) + expect(resource.vm?).to eq(false) + end end end describe '#tenant_id' do it 'returns the correct tenant ID' do