From add80d2831ac42d145d3d1e4cd4d701fbaf19ddf Mon Sep 17 00:00:00 2001 From: Aaron Kalin and Veezus Kreist Date: Wed, 25 May 2011 13:23:02 -0500 Subject: [PATCH] Conform to project standards --- lib/guard/dsl.rb | 5 ++--- spec/guard/dsl_spec.rb | 5 +++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/guard/dsl.rb b/lib/guard/dsl.rb index e0f41b5..9e993bd 100644 --- a/lib/guard/dsl.rb +++ b/lib/guard/dsl.rb @@ -23,8 +23,7 @@ module Guard end def guardfile_path - return local_guardfile_path if File.exist? local_guardfile_path - home_guardfile_path + File.exist?(local_guardfile_path) ? local_guardfile_path : home_guardfile_path end private @@ -33,7 +32,7 @@ module Guard end def home_guardfile_path - File.join(ENV['HOME'], "Guardfile") + File.expand_path(File.join("~", "Guardfile")) end end diff --git a/spec/guard/dsl_spec.rb b/spec/guard/dsl_spec.rb index 140bd52..b15ac84 100644 --- a/spec/guard/dsl_spec.rb +++ b/spec/guard/dsl_spec.rb @@ -23,21 +23,25 @@ describe Guard::Dsl do describe ".guardfile_path" do let(:local_path) { File.join(Dir.pwd, 'Guardfile') } let(:user_path) { File.join(ENV["HOME"], 'Guardfile') } + before do File.stub(:exist? => false) end + context "when there is a local Guardfile" do it "returns the path to the local Guardfile" do File.stub(:exist?).with(local_path).and_return(true) subject.guardfile_path.should == local_path end end + context "when there is a Guardfile in the user's home directory" do it "returns the path to the user Guardfile" do File.stub(:exist?).with(user_path).and_return(true) subject.guardfile_path.should == user_path end end + context "when there's both a local and user Guardfile" do it "returns the path to the local Guardfile" do File.stub(:exist?).with(local_path).and_return(true) @@ -45,6 +49,7 @@ describe Guard::Dsl do subject.guardfile_path.should == local_path end end + end describe ".guardfile_include?" do