Skip to content

Commit

Permalink
Conform to project standards
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaron Kalin and Veezus Kreist authored and hashrocketeer committed May 25, 2011
1 parent debdecb commit add80d2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
5 changes: 2 additions & 3 deletions lib/guard/dsl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ def guardfile_include?(guard_name)
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
Expand All @@ -33,7 +32,7 @@ def local_guardfile_path
end

def home_guardfile_path
File.join(ENV['HOME'], "Guardfile")
File.expand_path(File.join("~", "Guardfile"))
end
end

Expand Down
5 changes: 5 additions & 0 deletions spec/guard/dsl_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,28 +23,33 @@
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)
File.stub(:exist?).with(user_path).and_return(true)
subject.guardfile_path.should == local_path
end
end

end

describe ".guardfile_include?" do
Expand Down

0 comments on commit add80d2

Please sign in to comment.