Sha256: c8ce79e0963bf2cddb2852f34edd2f278e8e566255a517bfeb23988102f4e88e

Contents?: true

Size: 1.42 KB

Versions: 6

Compression:

Stored size: 1.42 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 = "test_plugins/sshkey_test"
      Dir.stub!(:pwd).and_return ::File.dirname(__FILE__)
      
      @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 =~ /test_plugins\/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

6 entries across 6 versions & 2 rubygems

Version Path
auser-poolparty-1.1.1 spec/poolparty/poolparty/key_spec.rb
auser-poolparty-1.1.3 spec/poolparty/poolparty/key_spec.rb
auser-poolparty-1.1.4 spec/poolparty/poolparty/key_spec.rb
auser-poolparty-1.1.5 spec/poolparty/poolparty/key_spec.rb
fairchild-poolparty-1.1.3 spec/poolparty/poolparty/key_spec.rb
fairchild-poolparty-1.1.4 spec/poolparty/poolparty/key_spec.rb