Skip to content
Browse files

Conform to project standards

  • Loading branch information...
1 parent debdecb commit add80d2831ac42d145d3d1e4cd4d701fbaf19ddf Aaron Kalin and Veezus Kreist committed with Hashrocket Workstation May 25, 2011
Showing with 7 additions and 3 deletions.
  1. +2 −3 lib/guard/dsl.rb
  2. +5 −0 spec/guard/dsl_spec.rb
View
5 lib/guard/dsl.rb
@@ -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
@@ -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
View
5 spec/guard/dsl_spec.rb
@@ -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

0 comments on commit add80d2

Please sign in to comment.
Something went wrong with that request. Please try again.