From 4f5e77d18936a34d46db1c710fc3c87395a503f7 Mon Sep 17 00:00:00 2001 From: Jacob Buys Date: Sun, 21 Aug 2011 22:14:18 +0200 Subject: [PATCH] Refactored tests to use `given_castle` and fewer mocks. --- spec/homesick_spec.rb | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/spec/homesick_spec.rb b/spec/homesick_spec.rb index 5a955c7..832a523 100644 --- a/spec/homesick_spec.rb +++ b/spec/homesick_spec.rb @@ -7,17 +7,17 @@ describe "homesick" do context "of a file" do it "should symlink existing directories" do somewhere = create_construct - somewhere.directory('wtf') - wtf = somewhere + 'wtf' + local_repo = somewhere.directory('wtf') - homesick.should_receive(:ln_s).with(wtf, wtf.basename) + homesick.clone local_repo - homesick.clone wtf + @repos_dir.join("wtf").readlink.should == local_repo end context "when it exists in a repo directory" do before do - @existing_dir = @repos_dir.directory('existing_castle') + @existing_castle = given_castle("existing_castle") + @existing_dir = @existing_castle.parent end it "should not symlink" do @@ -27,10 +27,7 @@ describe "homesick" do 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) + expect { homesick.clone @existing_dir.to_s }.to raise_error(/already cloned/i) end end end @@ -72,9 +69,7 @@ describe "homesick" do end it "should throw an exception when trying to clone a malformed uri like malformed" do - lambda { - homesick.clone 'malformed' - }.should raise_error + expect { homesick.clone 'malformed' }.to raise_error end it "should clone a github repo" do