Sha256: a1545cf065e8b3113e05a883e09602ec918b261b283b053067e27ea8cf5cabcd

Contents?: true

Size: 1.93 KB

Versions: 16

Compression:

Stored size: 1.93 KB

Contents

require File.dirname(__FILE__) + '/../../../spec_helper'

describe 'Fog::AWS::EC2::KeyPair' do

  describe "#initialize" do

    it "should remap attributes from parser" do
      key_pair = Fog::AWS::EC2::KeyPair.new(
        'keyFingerprint'  => 'fingerprint',
        'keyMaterial'     => 'material',
        'keyName'         => 'name'
      )
      key_pair.fingerprint.should == 'fingerprint'
      key_pair.material.should == 'material'
      key_pair.name.should == 'name'
    end

  end

  describe "#key_pairs" do

    it "should return a Fog::AWS::EC2::KeyPairs" do
      ec2.key_pairs.new.key_pairs.should be_a(Fog::AWS::EC2::KeyPairs)
    end

    it "should be the key_pairs the keypair is related to" do
      key_pairs = ec2.key_pairs
      key_pairs.new.key_pairs.should == key_pairs
    end

  end

  describe "#destroy" do

    it "should return true if the key_pair is deleted" do
      address = ec2.key_pairs.create(:name => 'keyname')
      address.destroy.should be_true
    end

  end

  describe "#reload" do

    before(:each) do
      @key_pair = ec2.key_pairs.create(:name => 'keyname')
      @reloaded = @key_pair.reload
    end

    after(:each) do
      @key_pair.destroy
    end

    it "should return a Fog::AWS::EC2::KeyPair" do
      @reloaded.should be_a(Fog::AWS::EC2::KeyPair)
    end

    it "should reset attributes to remote state" do
      @key_pair.attributes.should == @reloaded.attributes
    end

  end

  describe "#save" do

    before(:each) do
      @key_pair = ec2.key_pairs.new(:name => 'keyname')
    end

    it "should return true when it succeeds" do
      @key_pair.save.should be_true
      @key_pair.destroy
    end

    it "should not exist in key_pairs before save" do
      @key_pair.key_pairs.get(@key_pair.name).should be_nil
    end

    it "should exist in buckets after save" do
      @key_pair.save
      @key_pair.key_pairs.get(@key_pair.name).should_not be_nil
      @key_pair.destroy
    end

  end

end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
fog-0.0.29 spec/aws/models/ec2/key_pair_spec.rb
fog-0.0.28 spec/aws/models/ec2/key_pair_spec.rb
fog-0.0.27 spec/aws/models/ec2/key_pair_spec.rb
fog-0.0.26 spec/aws/models/ec2/key_pair_spec.rb
fog-0.0.25 spec/aws/models/ec2/key_pair_spec.rb
fog-0.0.24 spec/aws/models/ec2/key_pair_spec.rb
fog-0.0.23 spec/aws/models/ec2/key_pair_spec.rb
fog-0.0.22 spec/aws/models/ec2/key_pair_spec.rb
fog-0.0.21 spec/aws/models/ec2/key_pair_spec.rb
fog-0.0.20 spec/aws/models/ec2/key_pair_spec.rb
fog-0.0.19 spec/aws/models/ec2/key_pair_spec.rb
fog-0.0.18 spec/aws/models/ec2/key_pair_spec.rb
fog-0.0.17 spec/aws/models/ec2/key_pair_spec.rb
fog-0.0.16 spec/aws/models/ec2/key_pair_spec.rb
fog-0.0.15 spec/aws/models/ec2/key_pair_spec.rb
fog-0.0.14 spec/aws/models/ec2/key_pair_spec.rb