From 4fa7ce416b64eb796792dfc8685f04f4ad53b1d9 Mon Sep 17 00:00:00 2001 From: Jacob Buys Date: Sun, 21 Aug 2011 22:04:57 +0200 Subject: [PATCH] Made specs for `list` pass, refactored `track` to use given_castle. --- lib/homesick.rb | 2 +- spec/homesick_spec.rb | 25 +++++++++---------------- 2 files changed, 10 insertions(+), 17 deletions(-) diff --git a/lib/homesick.rb b/lib/homesick.rb index d156226..afe98f4 100644 --- a/lib/homesick.rb +++ b/lib/homesick.rb @@ -116,7 +116,7 @@ class Homesick < Thor desc "list", "List cloned castles" def list inside_each_castle do |castle| - say_status castle.relative_path_from(repos_dir), `git config remote.origin.url`.chomp, :cyan + say_status castle.relative_path_from(repos_dir).to_s, `git config remote.origin.url`.chomp, :cyan end end diff --git a/spec/homesick_spec.rb b/spec/homesick_spec.rb index 93e2db7..5a955c7 100644 --- a/spec/homesick_spec.rb +++ b/spec/homesick_spec.rb @@ -98,9 +98,7 @@ describe "homesick" do end describe "list" do - - # FIXME only passes in isolation. need to setup data a bit better - xit "should say each castle in the castle directory" do + it "should say each castle in the castle directory" do given_castle('zomg') given_castle('zomg', 'wtf/zomg') @@ -123,21 +121,16 @@ describe "homesick" do describe "track" do it "should move the tracked file into the castle" do + castle = given_castle('castle_repo') + some_rc_file = @user_dir.file '.some_rc_file' - homesickrepo = @user_dir.directory('.homesick').directory('repos').directory('castle_repo') - castle_path = homesickrepo.directory 'home' - - # There is some hideous thing going on with construct; rming the file I'm moving works on this test. - # Otherwise when track ln_s's it back out, it sees a conflict. Its as if file operations don't - # actually effect this thing, or something. - system "rm #{some_rc_file.to_s}" - Dir.chdir homesickrepo do - system "git init >/dev/null 2>&1" - end - - homesick.should_receive(:mv).with(some_rc_file, castle_path) - homesick.should_receive(:ln_s).with(castle_path + some_rc_file.basename, some_rc_file) + homesick.track(some_rc_file.to_s, 'castle_repo') + + tracked_file = castle.join(".some_rc_file") + tracked_file.should exist + + some_rc_file.readlink.should == tracked_file end end end