Skip to content

Commit

Permalink
Merge pull request #73 from johnbintz/symbols-for-group-names
Browse files Browse the repository at this point in the history
Allow symbols for group names
  • Loading branch information
Rémy Coutable committed Jun 1, 2011
2 parents 048ed9c + b0d3090 commit 53adfc9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/guard/dsl.rb
Expand Up @@ -90,7 +90,7 @@ def home_guardfile_path
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)) guard_definition.call if guard_definition && (@@options[:group].empty? || @@options[:group].include?(name.to_s))
end end


def guard(name, options = {}, &watch_definition) def guard(name, options = {}, &watch_definition)
Expand Down
14 changes: 12 additions & 2 deletions spec/guard/dsl_spec.rb
Expand Up @@ -186,7 +186,11 @@
end end


describe "#group" do describe "#group" do
it "should evaluates only the specified group" do it "should evaluates only the specified string group" do
::Guard.should_receive(:add_guard).with('test', anything, {})
lambda { subject.evaluate_guardfile(:guardfile_contents => valid_guardfile_string, :group => ['w']) }.should_not raise_error
end
it "should evaluates only the specified symbol group" do
::Guard.should_receive(:add_guard).with('test', anything, {}) ::Guard.should_receive(:add_guard).with('test', anything, {})
lambda { subject.evaluate_guardfile(:guardfile_contents => valid_guardfile_string, :group => ['x']) }.should_not raise_error lambda { subject.evaluate_guardfile(:guardfile_contents => valid_guardfile_string, :group => ['x']) }.should_not raise_error
end end
Expand Down Expand Up @@ -251,7 +255,13 @@ def fake_guardfile(name, contents)
end end


def valid_guardfile_string def valid_guardfile_string
"group 'x' do "group 'w' do
guard 'test' do
watch('c')
end
end
group :x do
guard 'test' do guard 'test' do
watch('c') watch('c')
end end
Expand Down

0 comments on commit 53adfc9

Please sign in to comment.