Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Support for dashes in guard names #66

Merged
merged 1 commit into from

2 participants

@johnbintz

I want to release a guard gem for jasmine-headless-webkit, and, before this patch, the class name Guard::JasmineHeadlessWebkit was unresolvable due to the preservation of dashes in the class name search. This removes the dashes from the class name search string so that the class name can be found correctly.

@thibaudgg thibaudgg merged commit ce2a5c5 into from
@thibaudgg
Owner

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on May 23, 2011
  1. @johnbintz
This page is out of date. Refresh to see the latest.
Showing with 12 additions and 1 deletion.
  1. +1 −1  lib/guard.rb
  2. +11 −0 spec/guard_spec.rb
View
2  lib/guard.rb
@@ -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
View
11 spec/guard_spec.rb
@@ -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
Something went wrong with that request. Please try again.