Sha256: 1e884b5dd466e363bfdafb66e29c6affc11e49cec13be21128def88e5ff917e6

Contents?: true

Size: 1.06 KB

Versions: 16

Compression:

Stored size: 1.06 KB

Contents

require 'mccloud'
require 'fileutils'
require 'tempfile'
require 'mccloud/keypair'

describe "Keypair" do

  before(:each) do
   @tempdir = Dir.mktmpdir
   @env=Mccloud::Environment.new(:cwd => @tempdir,:autoload => false)
   @env.ssh_key_path=@tempdir
  end

  after(:each) do
    @env=nil
    FileUtils.remove_entry_secure @tempdir
  end

  it "When I generate a non-existing pair, the public and private key should be created" do
    k=::Mccloud::Keypair.new("mccloud",@env)
    k.generate
    File.exists?(File.join(@env.ssh_key_path,"mccloud_rsa.pub")).should == true
    File.exists?(File.join(@env.ssh_key_path,"mccloud_rsa")).should == true
  end

  it "When I generate a existing pair, there should be an error" do
    k=::Mccloud::Keypair.new("mccloud",@env)
    k.generate
    expect { k.generate }.to raise_error(Mccloud::Error)
  end

  it "When I generate a existing pair,and I force the creation there should be no error" do
    k=::Mccloud::Keypair.new("mccloud",@env)
    k.generate
    expect { k.generate({:force => true}) }.to_not raise_error(Mccloud::Error)
  end

end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
mccloud-0.1.1 spec/keypair_spec.rb
mccloud-0.0.28 spec/keypair_spec.rb
mccloud-0.0.27 spec/keypair_spec.rb
mccloud-0.0.26 spec/keypair_spec.rb
mccloud-0.0.25 spec/keypair_spec.rb
mccloud-0.0.24 spec/keypair_spec.rb
mccloud-0.0.23 spec/keypair_spec.rb
mccloud-0.0.22 spec/keypair_spec.rb
mccloud-0.0.21 spec/keypair_spec.rb
mccloud-0.0.20 spec/keypair_spec.rb
mccloud-0.0.19 spec/keypair_spec.rb
mccloud-0.0.18 spec/keypair_spec.rb
mccloud-0.0.17 spec/keypair_spec.rb
mccloud-0.0.16 spec/keypair_spec.rb
mccloud-0.0.15 spec/keypair_spec.rb
mccloud-0.0.14 spec/keypair_spec.rb