Skip to content

Commit

Permalink
Allow look up fallback, so non Thor class does not obfuscate Thor tasks.
Browse files Browse the repository at this point in the history
  • Loading branch information
josevalim committed Jun 2, 2009
1 parent 578fa98 commit 20032b5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
1 change: 0 additions & 1 deletion lib/thor/util.rb
Expand Up @@ -187,7 +187,6 @@ def self.namespace_to_thor_class(namespace)

if klass
return klass, nil if klass <= Thor || klass <= Thor::Generator
raise Error, "'#{klass}' is not a Thor or Thor::Generator class"
elsif !namespace.include?(?:)
raise Error, "could not find Thor class or task '#{namespace}'"
end
Expand Down
12 changes: 6 additions & 6 deletions spec/util_spec.rb
Expand Up @@ -143,13 +143,13 @@
Thor::Util.namespace_to_thor_class("thor:help").must == [Thor, "help"]
end

describe 'errors' do
it "raises an error if the task does not inherit from Thor" do
lambda {
Thor::Util.namespace_to_thor_class("object")
}.must raise_error(Thor::Error, "'Object' is not a Thor or Thor::Generator class")
end
it "fallbacks in the namespace:task look up even if a full namespace does not match" do
Thor.const_set(:Help, Module.new)
Thor::Util.namespace_to_thor_class("thor:help").must == [Thor, "help"]
Thor.send :remove_const, :Help
end

describe 'errors' do
it "raises an error if the Thor class or task can't be found" do
lambda {
Thor::Util.namespace_to_thor_class("foobar")
Expand Down

0 comments on commit 20032b5

Please sign in to comment.