support for dashes in guard names

This commit is contained in:
John Bintz 2011-05-23 19:07:12 -04:00
parent 492b5a4114
commit 310bc5b644
2 changed files with 12 additions and 1 deletions

View File

@ -82,7 +82,7 @@ module Guard
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

View File

@ -57,6 +57,17 @@ describe Guard do
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