Sha256: e942cf91ac1dc252111e342bcc64709a58b1c1c024c6b204db5389bd5776eb52

Contents?: true

Size: 1.44 KB

Versions: 1

Compression:

Stored size: 1.44 KB

Contents

require 'spec_helper'

describe Mulder::Instance do

  let(:attributes) { { id: "i-f17bf19e", dns_name: 'foo.example.org', public_ip_address: '10.0.0.2', private_ip_address: '10.1.1.1', availability_zone: 'us-east-1a', vpc_id: 'vpc-e9663d87', created_at: DateTime.parse('2013-09-10 19:39:26 UTC').to_s } }

  describe '.new' do
    it 'stores the fog computer instance' do
      fog_compute_instance = mock
      described_class.new(fog_compute_instance).fog_compute_instance.should == fog_compute_instance
    end
  end

  describe '#exists?' do
    context 'when there is a compute instance' do
      it 'returns true' do
        fog_compute_instance = mock
        described_class.new(fog_compute_instance).should exist
      end
    end

    context 'when there no compute instance' do
      it 'returns false' do
        described_class.new(nil).should_not exist
      end
    end
  end

  describe '#as_hash' do
    let(:instance) { mock(attributes) }

    it 'has the expected attributes' do
      described_class.new(instance).as_hash.should == attributes
    end

    it 'rejects blank values' do
      instance = mock(attributes.merge(id: ''))
      described_class.new(instance).as_hash.should ==
        attributes.reject { |key, _| key == :id }
    end

    it 'rejects nil values' do
      instance = mock(attributes.merge(id: nil))
      described_class.new(instance).as_hash.should ==
        attributes.reject { |key, _| key == :id }
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mulder-0.4.0 spec/lib/mulder/instance_spec.rb