Moving towards testing list more.

This commit is contained in:
Joshua Nichols
2010-04-01 20:59:24 -04:00
parent c50464e366
commit 0579f94430
3 changed files with 26 additions and 8 deletions

View File

@@ -54,11 +54,9 @@ class Homesick < Thor
desc "list", "List cloned castles" desc "list", "List cloned castles"
def list def list
inside repos_dir do Pathname.glob(repos_dir + "*") do |castle|
Pathname.glob('*') do |home| Dir.chdir castle do # so we can call git config from the right contxt
inside home do say_status castle.basename.to_s, `git config remote.origin.url`.chomp, :cyan
say_status home, `git config remote.origin.url`, :cyan
end
end end
end end
end end
@@ -67,11 +65,11 @@ class Homesick < Thor
no_tasks do no_tasks do
# class method, so it's convenient to stub out during tests # class method, so it's convenient to stub out during tests
def self.user_dir def self.user_dir
@user_dir ||= Pathname.new('~').expand_path @user_dir ||= Pathname.new(ENV['HOME'] || '~').expand_path
end end
def self.repos_dir def self.repos_dir
@repos_dir ||= Pathname.new('~/.homesick/repos').expand_path @repos_dir ||= user_dir.join('.homesick', 'repos').expand_path
end end
def repos_dir def repos_dir

View File

@@ -30,4 +30,24 @@ describe Homesick do
@homesick.clone "wfarr/dotfiles" @homesick.clone "wfarr/dotfiles"
end end
end 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
@user_dir.directory '.homesick/repos' do |repos_dir|
repos_dir.directory 'zomg' do |zomg|
Dir.chdir do
system "git init >/dev/null 2>&1"
system "git remote add origin git://github.com/technicalpickles/zomg.git >/dev/null 2>&1"
end
end
end
@homesick.should_receive(:say_status).with("zomg", "git://github.com/technicalpickles/zomg.git", :cyan)
@homesick.list
end
end
end end

View File

@@ -10,7 +10,7 @@ Spec::Runner.configure do |config|
config.before do config.before do
@user_dir = create_construct @user_dir = create_construct
Homesick.stub!(:user_dir).and_return(@user_dir) ENV['HOME'] = @user_dir.to_s
end end
config.after do config.after do