diff --git a/lib/guard/dsl.rb b/lib/guard/dsl.rb index dc39f28..aa78735 100644 --- a/lib/guard/dsl.rb +++ b/lib/guard/dsl.rb @@ -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]}." diff --git a/spec/guard/dsl_spec.rb b/spec/guard/dsl_spec.rb index 83c2f68..f50c707 100644 --- a/spec/guard/dsl_spec.rb +++ b/spec/guard/dsl_spec.rb @@ -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