diff --git a/lib/homesick.rb b/lib/homesick.rb index ec31a49..57225a7 100644 --- a/lib/homesick.rb +++ b/lib/homesick.rb @@ -46,10 +46,15 @@ class Homesick < Thor protected - def user_dir + # class method, so it's convenient to stub out during tests + def self.user_dir @user_dir ||= Pathname.new('~').expand_path end + def user_dir + self.class.user_dir + end + def homes_dir @homes_dir ||= Pathname.new('~/.homesick/repos').expand_path end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 2cf79bb..821d9ba 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -7,4 +7,13 @@ require 'construct' Spec::Runner.configure do |config| config.include Construct::Helpers + + config.before do + @user_dir = create_construct + Homesick.stub!(:user_dir).and_return(@user_dir) + end + + config.after do + @user_dir.destroy! + end end