Raise Errno::ENOENT instead of RuntimeError from Pathname#install
This commit is contained in:
parent
284389a6bd
commit
c259866517
@ -35,6 +35,8 @@ class Pathname
|
||||
end
|
||||
|
||||
def install_p src, new_basename = nil
|
||||
raise Errno::ENOENT, src.to_s unless File.symlink?(src) || File.exist?(src)
|
||||
|
||||
if new_basename
|
||||
new_basename = File.basename(new_basename) # rationale: see Pathname.+
|
||||
dst = self+new_basename
|
||||
@ -45,8 +47,6 @@ class Pathname
|
||||
src = src.to_s
|
||||
dst = dst.to_s
|
||||
|
||||
raise "#{src} does not exist" unless File.symlink? src or File.exist? src
|
||||
|
||||
dst = yield(src, dst) if block_given?
|
||||
|
||||
mkpath
|
||||
|
||||
@ -83,9 +83,7 @@ class PathnameExtensionTests < Homebrew::TestCase
|
||||
end
|
||||
|
||||
def test_install_missing_file
|
||||
assert_raises(RuntimeError) do
|
||||
@dst.install 'non_existent_file'
|
||||
end
|
||||
assert_raises(Errno::ENOENT) { @dst.install "non_existent_file" }
|
||||
end
|
||||
|
||||
def test_install_removes_original
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user