In Ruby < 1.9, Symbol#downcase doesn't exist!
This commit is contained in:
parent
3d52d51d36
commit
cb5843aa47
@ -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))
|
||||
|
@ -81,14 +81,14 @@ module Guard
|
||||
end
|
||||
|
||||
def get_guard_class(name)
|
||||
try_to_load_gem name
|
||||
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
|
||||
|
||||
|
@ -89,6 +89,19 @@ describe Guard do
|
||||
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
|
||||
if Gem::Version.create(Gem::VERSION) >= Gem::Version.create('1.8.0')
|
||||
|
Loading…
Reference in New Issue
Block a user