Conform to project standards

This commit is contained in:
Aaron Kalin and Veezus Kreist 2011-05-25 13:23:02 -05:00 committed by Hashrocket Workstation
parent debdecbbd7
commit add80d2831
2 changed files with 7 additions and 3 deletions

View File

@ -23,8 +23,7 @@ module Guard
end end
def guardfile_path def guardfile_path
return local_guardfile_path if File.exist? local_guardfile_path File.exist?(local_guardfile_path) ? local_guardfile_path : home_guardfile_path
home_guardfile_path
end end
private private
@ -33,7 +32,7 @@ module Guard
end end
def home_guardfile_path def home_guardfile_path
File.join(ENV['HOME'], "Guardfile") File.expand_path(File.join("~", "Guardfile"))
end end
end end

View File

@ -23,21 +23,25 @@ describe Guard::Dsl do
describe ".guardfile_path" do describe ".guardfile_path" do
let(:local_path) { File.join(Dir.pwd, 'Guardfile') } let(:local_path) { File.join(Dir.pwd, 'Guardfile') }
let(:user_path) { File.join(ENV["HOME"], 'Guardfile') } let(:user_path) { File.join(ENV["HOME"], 'Guardfile') }
before do before do
File.stub(:exist? => false) File.stub(:exist? => false)
end end
context "when there is a local Guardfile" do context "when there is a local Guardfile" do
it "returns the path to the local Guardfile" do it "returns the path to the local Guardfile" do
File.stub(:exist?).with(local_path).and_return(true) File.stub(:exist?).with(local_path).and_return(true)
subject.guardfile_path.should == local_path subject.guardfile_path.should == local_path
end end
end end
context "when there is a Guardfile in the user's home directory" do context "when there is a Guardfile in the user's home directory" do
it "returns the path to the user Guardfile" do it "returns the path to the user Guardfile" do
File.stub(:exist?).with(user_path).and_return(true) File.stub(:exist?).with(user_path).and_return(true)
subject.guardfile_path.should == user_path subject.guardfile_path.should == user_path
end end
end end
context "when there's both a local and user Guardfile" do context "when there's both a local and user Guardfile" do
it "returns the path to the local Guardfile" do it "returns the path to the local Guardfile" do
File.stub(:exist?).with(local_path).and_return(true) File.stub(:exist?).with(local_path).and_return(true)
@ -45,6 +49,7 @@ describe Guard::Dsl do
subject.guardfile_path.should == local_path subject.guardfile_path.should == local_path
end end
end end
end end
describe ".guardfile_include?" do describe ".guardfile_include?" do