Use construct for stubbing user_dir.
This commit is contained in:
@@ -46,10 +46,15 @@ class Homesick < Thor
|
|||||||
|
|
||||||
protected
|
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
|
@user_dir ||= Pathname.new('~').expand_path
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def user_dir
|
||||||
|
self.class.user_dir
|
||||||
|
end
|
||||||
|
|
||||||
def homes_dir
|
def homes_dir
|
||||||
@homes_dir ||= Pathname.new('~/.homesick/repos').expand_path
|
@homes_dir ||= Pathname.new('~/.homesick/repos').expand_path
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -7,4 +7,13 @@ require 'construct'
|
|||||||
|
|
||||||
Spec::Runner.configure do |config|
|
Spec::Runner.configure do |config|
|
||||||
config.include Construct::Helpers
|
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
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user