Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

evaluate_guardfile uses all groups if none specified #119

Merged
merged 2 commits into from Aug 14, 2011
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/guard/dsl.rb
Expand Up @@ -104,7 +104,8 @@ def home_guardfile_path
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)
Expand Down
5 changes: 5 additions & 0 deletions spec/guard/dsl_spec.rb
Expand Up @@ -213,6 +213,11 @@
::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
Expand Down
4 changes: 3 additions & 1 deletion spec/support/listener_helper.rb
Expand Up @@ -8,9 +8,11 @@ def start
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

Expand Down