Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

In Ruby < 1.9, Symbol#downcase doesn't exist!

  • Loading branch information...
commit cb5843aa47ab61ef5008c3fb84028ec693d52259 1 parent 3d52d51
@rymai rymai authored
Showing with 20 additions and 3 deletions.
  1. +4 −0 CHANGELOG.md
  2. +3 −3 lib/guard.rb
  3. +13 −0 spec/guard_spec.rb
View
4 CHANGELOG.md
@@ -1,5 +1,9 @@
## Master
+### Bugs fixes:
+
+- In Ruby < 1.9, Symbol#downcase doesn't exist! ([@rymai](https://github.com/rymai))
+
### New features:
- Pull request [#73](https://github.com/guard/guard/pull/73): Allow DSL's `group` method to accept a Symbol as group name. ([@johnbintz](https://github.com/johnbintz))
View
6 lib/guard.rb
@@ -81,14 +81,14 @@ def add_guard(name, watchers = [], options = {})
end
def get_guard_class(name)
- try_to_load_gem name
- self.const_get(self.constants.find{ |klass_name| klass_name.to_s.downcase == name.to_s.downcase.gsub('-', '') })
+ try_to_load_gem(name)
+ self.const_get(self.constants.find { |klass_name| klass_name.to_s.downcase == name.to_s.downcase.gsub('-', '') })
rescue TypeError
UI.error "Could not find load find gem 'guard-#{name}' or find class Guard::#{name}"
end
def try_to_load_gem(name)
- require "guard/#{name.downcase}"
+ require "guard/#{name.to_s.downcase}"
rescue LoadError
end
View
13 spec/guard_spec.rb
@@ -88,6 +88,19 @@ class Inline < Guard
end
end
end
+
+ describe ".try_to_load_gem" do
+ class Guard::Classname
+ end
+
+ it "reports an error if the class is not found" do
+ Guard.get_guard_class('classname').should be_true
+ end
+
+ it "reports an error if the class is not found" do
+ Guard.get_guard_class(:classname).should be_true
+ end
+ end
describe ".locate_guard" do
it "returns the path of a Guard gem" do
Please sign in to comment.
Something went wrong with that request. Please try again.