Sha256: 7d4d664470ddddf09fa7e77987f0a8bfefb5805a4493020450036634cf8cbacb

Contents?: true

Size: 1.41 KB

Versions: 5

Compression:

Stored size: 1.41 KB

Contents

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

describe "Key" do
  it "be able to be instantiated with a keyfile" do
    lambda {Key.new("file")}.should_not raise_error
  end
  it "should fill in the filepath as id_rsa if no filelocation is given" do
    Key.new.filepath.should == "id_rsa"
  end
  it "should provide valid to_json" do
    lambda {Key.new("file").to_hash.to_json}.should_not raise_error  end
  describe "that exists" do
    before(:each) do
      @keypair = "/var/home/id_rsa"
      ::File.stub!(:file?).with(@keypair).and_return true
      ::File.stub!(:expand_path).with(@keypair).and_return @keypair
      
      @key = Key.new(@keypair)
    end
    it "say that the key exists" do
      @key.exists?.should == true
    end    
  end
  describe "that is not a full filepath name" do
    before(:each) do
      @keypair = "sshkey_test"      
      Dir.stub!(:pwd).and_return "#{::File.dirname(__FILE__)}/test_plugins"
      
      @key = Key.new(@keypair)
    end
    it "should search in known locations for the key" do
      @key.should_receive(:search_in_known_locations).and_return nil
      @key.full_filepath
    end
    it "return the full filepath when the key exists (checking last possible Dir.pwd)" do
      @key.full_filepath.should =~ /sshkey_test/
    end
    it "should return the content of the keyfile when requested" do
      @key.content.should == "-- THIS IS A TEST SSH KEY FILE --\n\n"
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
auser-poolparty-1.2.10 spec/poolparty/poolparty/key_spec.rb
auser-poolparty-1.2.11 spec/poolparty/poolparty/key_spec.rb
auser-poolparty-1.2.7 spec/poolparty/poolparty/key_spec.rb
auser-poolparty-1.2.8 spec/poolparty/poolparty/key_spec.rb
auser-poolparty-1.2.9 spec/poolparty/poolparty/key_spec.rb