Merge pull request #119 from ches/guard

---

After all my talking in #118, I thought I should fix it :-)
This commit is contained in:
Michael Kessler 2011-08-14 13:22:26 +02:00
commit fd405b3131
3 changed files with 10 additions and 2 deletions

View File

@ -104,7 +104,8 @@ module Guard
end end
def group(name, &guard_definition) 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 end
def guard(name, options = {}, &watch_definition) def guard(name, options = {}, &watch_definition)

View File

@ -213,6 +213,11 @@ describe Guard::Dsl do
::Guard.should_receive(:add_guard).with('another', anything, {}) ::Guard.should_receive(:add_guard).with('another', anything, {})
lambda { subject.evaluate_guardfile(:guardfile_contents => valid_guardfile_string, :group => ['x','y']) }.should_not raise_error lambda { subject.evaluate_guardfile(:guardfile_contents => valid_guardfile_string, :group => ['x','y']) }.should_not raise_error
end 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 end
# TODO: not sure if each seperate quoting/call type needs its own test # TODO: not sure if each seperate quoting/call type needs its own test

View File

@ -8,9 +8,11 @@ private
end end
def record_results def record_results
noise = %r|\.sw.$| # don't fail specs due to editor swap files, etc.
@results = [] @results = []
@listener.on_change do |files| @listener.on_change do |files|
@results += files @results += files.reject { |f| f =~ noise }
end end
end end