Skip to content

Commit

Permalink
fixing FakeFS::FakeSymLink#to_s (Closes #69)
Browse files Browse the repository at this point in the history
  • Loading branch information
jluxenberg authored and smtlaissezfaire committed Sep 5, 2011
1 parent 1597e76 commit d98a064
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/fakefs/fake/symlink.rb
@@ -1,7 +1,6 @@
module FakeFS
class FakeSymlink
attr_accessor :name, :target, :parent
alias_method :to_s, :name

def initialize(target)
@target = target
Expand All @@ -19,6 +18,10 @@ def delete
parent.delete(self)
end

def to_s
File.join(parent.to_s, name)
end

def respond_to?(method)
entry.respond_to?(method)
end
Expand Down
7 changes: 7 additions & 0 deletions test/fakefs_test.rb
Expand Up @@ -147,6 +147,13 @@ def test_symlinks_in_different_directories
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")
Expand Down

0 comments on commit d98a064

Please sign in to comment.