diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-12-16 12:26:52 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-12-16 12:26:52 +0000 |
commit | 4cf828632f3e2411b4c141fb30b2edf4844351fa (patch) | |
tree | d5bf190556e5adb71e270a84c1a2e0f88dc5ed04 /ext/pathname | |
parent | 13fd78c2e15eae8d742811bfe5c07bbf119616ae (diff) |
Pathname#relative_path_from compatible with mock.
[Fix GH-2049]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66416 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/pathname')
-rw-r--r-- | ext/pathname/lib/pathname.rb | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/ext/pathname/lib/pathname.rb b/ext/pathname/lib/pathname.rb index 7fb923c6ae..383d47b52f 100644 --- a/ext/pathname/lib/pathname.rb +++ b/ext/pathname/lib/pathname.rb @@ -503,9 +503,13 @@ class Pathname # ArgumentError is raised when it cannot find a relative path. # def relative_path_from(base_directory) - base_directory = Pathname.new(base_directory) unless Pathname === base_directory dest_directory = self.cleanpath.to_s - base_directory = base_directory.cleanpath.to_s + base_directory = + if base_directory.respond_to? :cleanpath + base_directory + else + Pathname.new(base_directory) + end.cleanpath.to_s dest_prefix = dest_directory dest_names = [] while r = chop_basename(dest_prefix) |