Skip to content

Commit

Permalink
support for dashes in guard names
Browse files Browse the repository at this point in the history
  • Loading branch information
johnbintz committed May 23, 2011
1 parent 492b5a4 commit 310bc5b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/guard.rb
Expand Up @@ -82,7 +82,7 @@ def add_guard(name, watchers = [], options = {})

def get_guard_class(name)
try_to_load_gem name
self.const_get(self.constants.find{ |klass_name| klass_name.to_s.downcase == name.downcase })
self.const_get(self.constants.find{ |klass_name| klass_name.to_s.downcase == name.downcase.gsub('-', '') })
rescue TypeError
UI.error "Could not find load find gem 'guard-#{name}' or find class Guard::#{name}"
end
Expand Down
11 changes: 11 additions & 0 deletions spec/guard_spec.rb
Expand Up @@ -57,6 +57,17 @@ class Guard::Classname
end
end

context 'with a name with dashes' do
it "returns the Guard class" do
Guard.should_receive(:try_to_load_gem) { |classname|
classname.should == 'dashed-class-name'
class Guard::DashedClassName
end
}
Guard.get_guard_class('dashed-class-name').should == Guard::DashedClassName
end
end

context 'with an inline Guard class' do
it 'returns the Guard class' do
module Guard
Expand Down

0 comments on commit 310bc5b

Please sign in to comment.