Use #[] instead of #has_key? since it is more flexible (accept symbol as key for actual string keys in the hash).

This commit is contained in:
Rémy Coutable 2011-07-29 09:05:40 +02:00
parent a6d0dab45c
commit 6b30238735
2 changed files with 9 additions and 5 deletions

View File

@ -45,12 +45,11 @@ module Guard
def fetch_guardfile_contents
# TODO: do we need .rc file interaction?
if @@options.has_key?(:guardfile_contents)
if @@options[:guardfile_contents]
UI.info "Using inline Guardfile."
@@options[:guardfile_path] = 'Inline Guardfile'
elsif @@options.has_key?(:guardfile)
UI.debug File.exist?(@@options[:guardfile])
elsif @@options[:guardfile]
if File.exist?(@@options[:guardfile])
read_guardfile(@@options[:guardfile])
UI.info "Using Guardfile at #{@@options[:guardfile]}."

View File

@ -17,6 +17,7 @@ describe Guard::Dsl do
lambda { subject.evaluate_guardfile(:guardfile_contents => valid_guardfile_string) }.should_not raise_error
subject.guardfile_contents.should == valid_guardfile_string
end
it "should use a -command file over the default loc" do
fake_guardfile('/abc/Guardfile', "guard :foo")
@ -115,9 +116,13 @@ describe Guard::Dsl do
end
it "should raise error when guardfile_content ends up empty or nil" do
Guard::UI.should_receive(:error).twice.with(/The command file/)
Guard::UI.should_receive(:error).with(/The command file/)
lambda { subject.evaluate_guardfile(:guardfile_contents => "") }.should raise_error
lambda { subject.evaluate_guardfile(:guardfile_contents => nil) }.should raise_error
end
it "should not raise error when guardfile_content is nil (skipped)" do
Guard::UI.should_not_receive(:error)
lambda { subject.evaluate_guardfile(:guardfile_contents => nil) }.should_not raise_error
end
end