Don't try to symlink a castle to itself. Fixes #14

This commit is contained in:
Josh Nichols
2011-05-30 21:04:41 -04:00
parent 54697866f5
commit e19617be2f
2 changed files with 35 additions and 7 deletions

View File

@@ -6,14 +6,37 @@ describe "homesick" do
end
describe "clone" do
it "should symlink existing directories" do
somewhere = create_construct
somewhere.directory('wtf')
wtf = somewhere + 'wtf'
context "of a file" do
it "should symlink existing directories" do
somewhere = create_construct
somewhere.directory('wtf')
wtf = somewhere + 'wtf'
@homesick.should_receive(:ln_s).with(wtf.to_s, wtf.basename)
@homesick.should_receive(:ln_s).with(wtf, wtf.basename)
@homesick.clone wtf.to_s
@homesick.clone wtf
end
context "when it exists in a repo directory" do
before do
@repos_dir = create_construct
@existing_dir = @repos_dir.directory('existing_castle')
@homesick.stub!(:repos_dir).and_return(@repos_dir)
end
it "should not symlink" do
@homesick.should_not_receive(:git_clone)
@homesick.clone @existing_dir.to_s rescue nil
end
it "should raise an error" do
@existing_castle = @homesick.send(:repos_dir) + 'existing_castle'
lambda {
@homesick.clone @existing_castle.to_s
}.should raise_error(/already cloned/i)
end
end
end
it "should clone git repo like git://host/path/to.git" do