Sha256: 600a1f7fbbf10287e5e70ff29e325e04da04c37f478548d7333be16484d52b37

Contents?: true

Size: 1.41 KB

Versions: 9

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_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

9 entries across 9 versions & 3 rubygems

Version Path
auser-poolparty-1.1.6 spec/poolparty/poolparty/key_spec.rb
auser-poolparty-1.1.7 spec/poolparty/poolparty/key_spec.rb
auser-poolparty-1.2.0 spec/poolparty/poolparty/key_spec.rb
auser-poolparty-1.2.1 spec/poolparty/poolparty/key_spec.rb
auser-poolparty-1.2.2 spec/poolparty/poolparty/key_spec.rb
auser-poolparty-1.2.3 spec/poolparty/poolparty/key_spec.rb
auser-poolparty-1.2.4 spec/poolparty/poolparty/key_spec.rb
fairchild-poolparty-1.1.5 spec/poolparty/poolparty/key_spec.rb
poolparty-1.2.2 spec/poolparty/poolparty/key_spec.rb