From 4cf828632f3e2411b4c141fb30b2edf4844351fa Mon Sep 17 00:00:00 2001 From: akr Date: Sun, 16 Dec 2018 12:26:52 +0000 Subject: 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 --- test/pathname/test_pathname.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'test') diff --git a/test/pathname/test_pathname.rb b/test/pathname/test_pathname.rb index 3bea182ed4..fbf4bb3459 100644 --- a/test/pathname/test_pathname.rb +++ b/test/pathname/test_pathname.rb @@ -1429,4 +1429,18 @@ class TestPathname < Test::Unit::TestCase assert_instance_of(Pathname, foo.relative_path_from(bar)) end; end + + def test_relative_path_from_mock + assert_equal( + Pathname.new("../bar"), + Pathname.new("/foo/bar").relative_path_from(Pathname.new("/foo/baz"))) + assert_equal( + Pathname.new("../bar"), + Pathname.new("/foo/bar").relative_path_from("/foo/baz")) + obj = Object.new + def obj.cleanpath() Pathname.new("/foo/baz") end + assert_equal( + Pathname.new("../bar"), + Pathname.new("/foo/bar").relative_path_from(obj)) + end end -- cgit v1.2.3