Use prefix comparison between paths, use UI.path for printing

parent 709ac1af
......@@ -115,9 +115,9 @@ module Pod
def prepare
# Raise if pwd is inside Pods
if (Pathname.pwd <=> sandbox.root) >= 0
if Dir.pwd.start_with?(sandbox.root.to_path)
message = 'Command should be run from a directory outside Pods directory.'
message << "\n\n\tCurrent directory is '#{Pathname.pwd}'\n"
message << "\n\n\tCurrent directory is #{UI.path(Pathname.pwd)}\n"
raise Informative, message
end
UI.message 'Preparing' do
......
......@@ -166,11 +166,17 @@ module Pod
UI.warnings.should.include 'BlocksKit has been deprecated'
end
it 'raises if command is run inside sandbox directory' do
it 'does not raise if command is run outside sandbox directory' do
Dir.chdir(@installer.sandbox.root.parent) do
should.not.raise(Informative) { @installer.install! }
end
end
it 'raises if command is run in sandbox directory' do
Dir.chdir(@installer.sandbox.root) do
should.raise Informative do
@installer.install!
end.message.should.match %r{should.*run.*outside.*Pods directory.*Current directory.*/Pods}m
end.message.should.match %r{should.*run.*outside.*Pods directory.*Current directory.*\.}m
end
end
end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment