Permalink
Browse files

Set the rakefile in Thor::RakeCompat relative to the current directory

  • Loading branch information...
1 parent bd9d0e8 commit a5483accd0f08e47cd8cfd71999cafe48b53df30 @josevalim josevalim committed Oct 18, 2009
Showing with 9 additions and 1 deletion.
  1. +5 −1 lib/thor/rake_compat.rb
  2. +4 −0 spec/rake_compat_spec.rb
View
@@ -21,8 +21,12 @@ def self.rake_classes
end
def self.included(base)
+ rakefile = caller[0].match(/(.*):\d+/)[1]
+ rakefile.gsub!(Dir.pwd, "")
+ rakefile.gsub!(/^\//, "")
+
# Hack. Make rakefile point to invoker, so rdoc task is generated properly.
- Rake.application.instance_variable_set(:@rakefile, caller[0].match(/(.*):\d+/)[1])
+ Rake.application.instance_variable_set(:@rakefile, rakefile)
self.rake_classes << base
end
end
View
@@ -27,6 +27,10 @@ class ThorTask < Thor
end
describe Thor::RakeCompat do
+ it "sets the rakefile application" do
+ Rake.application.rakefile.must =~ /rake_compat_spec.rb$/
+ end
+
it "adds rake tasks to thor classes too" do
task = ThorTask.tasks["cool"]
task.must be

0 comments on commit a5483ac

Please sign in to comment.