Use construct for stubbing user_dir.

This commit is contained in:
Joshua Nichols
2010-03-10 08:31:44 -05:00
parent 7fd44c7fe5
commit 3fb5f5b0d9
2 changed files with 15 additions and 1 deletions

View File

@@ -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

View File

@@ -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