Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add specs for File.realpath with invalid inputs

  • Loading branch information...
commit c792d9c5a9296c839a09b2860ff7087182310c74 1 parent 14f29ad
@kachick kachick authored brixen committed
Showing with 14 additions and 1 deletion.
  1. +14 −1 core/file/realpath_spec.rb
View
15 core/file/realpath_spec.rb
@@ -14,10 +14,15 @@
touch @file
File.symlink(@file, @link)
+
+ @fake_file = File.join(@real_dir, 'fake_file')
+ @fake_link = File.join(@link_dir, 'fake_link')
+
+ File.symlink(@fake_file, @fake_link)
end
after :each do
- rm_r @file, @link, @real_dir, @link_dir
+ rm_r @file, @link, @fake_link, @real_dir, @link_dir
end
it "returns '/' when passed '/'" do
@@ -43,5 +48,13 @@
File.symlink(@link, @link)
lambda { File.realpath(@link) }.should raise_error(Errno::ELOOP)
end
+
+ it "raises Errno::ENOENT if file is absent" do
+ lambda { File.realpath(@fake_file) }.should raise_error(Errno::ENOENT)
+ end
+
+ it "raises Errno::ENOENT if symlink points an absent file" do
+ lambda { File.realpath(@fake_link) }.should raise_error(Errno::ENOENT)
+ end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.