fixing FakeFS::FakeSymLink#to_s (Closes #69)

This commit is contained in:
Jared Luxenberg 2011-03-23 10:05:40 -07:00 committed by Scott Taylor
parent 1597e76c7f
commit d98a06473e
2 changed files with 11 additions and 1 deletions

View File

@ -1,7 +1,6 @@
module FakeFS
class FakeSymlink
attr_accessor :name, :target, :parent
alias_method :to_s, :name
def initialize(target)
@target = target
@ -19,6 +18,10 @@ module FakeFS
parent.delete(self)
end
def to_s
File.join(parent.to_s, name)
end
def respond_to?(method)
entry.respond_to?(method)
end

View File

@ -147,6 +147,13 @@ class FakeFSTest < Test::Unit::TestCase
assert_equal target, File.readlink(link)
end
def test_symlinks_to_symlinks
FileUtils.mkdir_p(target = "/path/to/foo/target")
FileUtils.ln_s(target, link1 = "/path/to/bar/symlink")
FileUtils.ln_s(link1, link2 = "/path/to/bar2/symlink")
assert_equal link1, File.readlink(link2)
end
def test_knows_symlinks_are_symlinks
FileUtils.mkdir_p(target = "/path/to/target")
FileUtils.ln_s(target, link = "/path/to/symlink")