Moving towards testing list more.
This commit is contained in:
@@ -54,11 +54,9 @@ class Homesick < Thor
|
||||
|
||||
desc "list", "List cloned castles"
|
||||
def list
|
||||
inside repos_dir do
|
||||
Pathname.glob('*') do |home|
|
||||
inside home do
|
||||
say_status home, `git config remote.origin.url`, :cyan
|
||||
end
|
||||
Pathname.glob(repos_dir + "*") do |castle|
|
||||
Dir.chdir castle do # so we can call git config from the right contxt
|
||||
say_status castle.basename.to_s, `git config remote.origin.url`.chomp, :cyan
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -67,11 +65,11 @@ class Homesick < Thor
|
||||
no_tasks do
|
||||
# class method, so it's convenient to stub out during tests
|
||||
def self.user_dir
|
||||
@user_dir ||= Pathname.new('~').expand_path
|
||||
@user_dir ||= Pathname.new(ENV['HOME'] || '~').expand_path
|
||||
end
|
||||
|
||||
def self.repos_dir
|
||||
@repos_dir ||= Pathname.new('~/.homesick/repos').expand_path
|
||||
@repos_dir ||= user_dir.join('.homesick', 'repos').expand_path
|
||||
end
|
||||
|
||||
def repos_dir
|
||||
|
||||
@@ -30,4 +30,24 @@ describe Homesick do
|
||||
@homesick.clone "wfarr/dotfiles"
|
||||
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
|
||||
|
||||
@@ -10,7 +10,7 @@ Spec::Runner.configure do |config|
|
||||
|
||||
config.before do
|
||||
@user_dir = create_construct
|
||||
Homesick.stub!(:user_dir).and_return(@user_dir)
|
||||
ENV['HOME'] = @user_dir.to_s
|
||||
end
|
||||
|
||||
config.after do
|
||||
|
||||
Reference in New Issue
Block a user