spec/ssh_key_spec.rb in jbox-gitolite-1.2.0 vs spec/ssh_key_spec.rb in jbox-gitolite-1.2.1
- old
+ new
@@ -1,12 +1,13 @@
require 'spec_helper'
-require 'gitolite/ssh_key'
-include Gitolite
describe Gitolite::SSHKey do
- key_dir = File.join(File.dirname(__FILE__),'keys')
+ key_dir = File.join(File.dirname(__FILE__), 'fixtures', 'keys')
+ output_dir = '/tmp'
+ # output_dir = File.join(File.dirname(File.dirname(__FILE__)), 'tmp')
+
describe "#from_string" do
it 'should construct an SSH key from a string' do
key = File.join(key_dir, 'bob.pub')
key_string = File.read(key)
s = SSHKey.from_string(key_string, "bob")
@@ -94,10 +95,16 @@
key = File.join(key_dir, 'bob.joe@test.zilla.com@desktop.pub')
s = SSHKey.from_file(key)
s.owner.should == 'bob.joe@test.zilla.com'
end
+ it "owner should be bob+joe@test.zilla.com for bob+joe@test.zilla.com@desktop.pub" do
+ key = File.join(key_dir, 'bob+joe@test.zilla.com@desktop.pub')
+ s = SSHKey.from_file(key)
+ s.owner.should == 'bob+joe@test.zilla.com'
+ end
+
it 'owner should be bob@zilla.com for bob@zilla.com@desktop.pub' do
key = File.join(key_dir, 'bob@zilla.com@desktop.pub')
s = SSHKey.from_file(key)
s.owner.should == 'bob@zilla.com'
end
@@ -311,14 +318,15 @@
owner = Forgery::Name.first_name
location = Forgery::Basic.text(:at_least => 8, :at_most => 15)
s = SSHKey.new(type, blob, email, owner, location)
- tmpdir = Dir.tmpdir
- s.to_file(tmpdir)
+ ## write file
+ s.to_file(output_dir)
- s.to_s.should == File.read(File.join(tmpdir, s.filename))
+ ## compare raw string with written file
+ s.to_s.should == File.read(File.join(output_dir, s.filename))
end
it 'should return the filename written' do
type = "ssh-rsa"
blob = Forgery::Basic.text(:at_least => 372, :at_most => 372)
@@ -326,13 +334,10 @@
owner = Forgery::Name.first_name
location = Forgery::Basic.text(:at_least => 8, :at_most => 15)
s = SSHKey.new(type, blob, email, owner, location)
- tmpdir = Dir.tmpdir
-
-
- s.to_file(tmpdir).should == File.join(tmpdir, s.filename)
+ s.to_file(output_dir).should == File.join(output_dir, s.filename)
end
end
describe '==' do
it 'should have two keys equalling one another' do