Skip to content

Commit

Permalink
bug 168 investigation
Browse files Browse the repository at this point in the history
  • Loading branch information
kbl committed Dec 20, 2011
1 parent 432f152 commit 1daac92
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/thor/actions.rb
Expand Up @@ -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.
Expand Down
4 changes: 4 additions & 0 deletions spec/actions_spec.rb
Expand Up @@ -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__)))
Expand Down

0 comments on commit 1daac92

Please sign in to comment.