Permalink
Browse files

Merge pull request #206 from kbl/bug-168-wrong-paths-on-output

Issue 168
  • Loading branch information...
2 parents 432f152 + 1daac92 commit bdf49a5f2df793c8806f617f96704bd77d3be710 @wycats wycats committed Dec 20, 2011
Showing with 10 additions and 2 deletions.
  1. +6 −2 lib/thor/actions.rb
  2. +4 −0 spec/actions_spec.rb
View
@@ -114,8 +114,12 @@ def destination_root=(root)
# the script started).
#
def relative_to_original_destination_root(path, remove_dot=true)
- path = path.gsub(@destination_stack[0], '.')
- remove_dot ? (path[2..-1] || '') : path
+ if path =~ /^#{@destination_stack[0]}/
+ path = path.gsub(@destination_stack[0], '.')
+ path = remove_dot ? (path[2..-1] || '') : path
+ end
+
+ path
end
# Holds source paths in instance so they can be manipulated.
View
@@ -82,6 +82,10 @@ def file
end
end
+ it "creates proper relative paths for absolute file location" do
+ runner.relative_to_original_destination_root('/test/file').should == "/test/file"
+ end
+
describe "#source_paths_for_search" do
it "add source_root to source_paths_for_search" do
MyCounter.source_paths_for_search.should include(File.expand_path("fixtures", File.dirname(__FILE__)))

0 comments on commit bdf49a5

Please sign in to comment.