From 87375c7a1ffdfcab1b10015ca6bb7706c41368ae Mon Sep 17 00:00:00 2001 From: Ches Martin Date: Sun, 14 Aug 2011 15:16:16 +0700 Subject: [PATCH 1/2] evaluate_guardfile uses all groups if none specified. Fixes #118 --- lib/guard/dsl.rb | 3 ++- spec/guard/dsl_spec.rb | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/guard/dsl.rb b/lib/guard/dsl.rb index aa78735..12ca379 100644 --- a/lib/guard/dsl.rb +++ b/lib/guard/dsl.rb @@ -104,7 +104,8 @@ module Guard end def group(name, &guard_definition) - guard_definition.call if guard_definition && (@@options[:group].empty? || @@options[:group].include?(name.to_s)) + @groups = @@options[:group] || [] + guard_definition.call if guard_definition && (@groups.empty? || @groups.include?(name.to_s)) end def guard(name, options = {}, &watch_definition) diff --git a/spec/guard/dsl_spec.rb b/spec/guard/dsl_spec.rb index f50c707..740d8ed 100644 --- a/spec/guard/dsl_spec.rb +++ b/spec/guard/dsl_spec.rb @@ -213,6 +213,11 @@ describe Guard::Dsl do ::Guard.should_receive(:add_guard).with('another', anything, {}) lambda { subject.evaluate_guardfile(:guardfile_contents => valid_guardfile_string, :group => ['x','y']) }.should_not raise_error end + it "should evaluate all groups when no group option is specified" do + ::Guard.should_receive(:add_guard).with('test', anything, {}).twice + ::Guard.should_receive(:add_guard).with('another', anything, {}).twice + lambda { subject.evaluate_guardfile(:guardfile_contents => valid_guardfile_string) }.should_not raise_error + end end # TODO: not sure if each seperate quoting/call type needs its own test From ca2a4fa1be2a0a1de98e31b566554cddae5484fe Mon Sep 17 00:00:00 2001 From: Ches Martin Date: Sun, 14 Aug 2011 15:16:59 +0700 Subject: [PATCH 2/2] Don't fail specs because of blasted vim swapfiles --- spec/support/listener_helper.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/spec/support/listener_helper.rb b/spec/support/listener_helper.rb index 03bc21b..85c9d78 100644 --- a/spec/support/listener_helper.rb +++ b/spec/support/listener_helper.rb @@ -8,9 +8,11 @@ private end def record_results + noise = %r|\.sw.$| # don't fail specs due to editor swap files, etc. + @results = [] @listener.on_change do |files| - @results += files + @results += files.reject { |f| f =~ noise } end end