2018-03-04 15:09:32 +00:00
|
|
|
require_relative '../../spec_helper'
|
2017-05-07 12:04:49 +00:00
|
|
|
|
|
|
|
describe "File.link" do
|
|
|
|
before :each do
|
|
|
|
@file = tmp("file_link.txt")
|
|
|
|
@link = tmp("file_link.lnk")
|
|
|
|
|
|
|
|
rm_r @link
|
|
|
|
touch @file
|
|
|
|
end
|
|
|
|
|
|
|
|
after :each do
|
|
|
|
rm_r @link, @file
|
|
|
|
end
|
|
|
|
|
2020-10-12 21:26:05 +09:00
|
|
|
platform_is_not :windows, :android do
|
2017-05-07 12:04:49 +00:00
|
|
|
it "link a file with another" do
|
|
|
|
File.link(@file, @link).should == 0
|
2019-09-29 19:13:37 +02:00
|
|
|
File.should.exist?(@link)
|
2017-05-07 12:04:49 +00:00
|
|
|
File.identical?(@file, @link).should == true
|
|
|
|
end
|
|
|
|
|
|
|
|
it "raises an Errno::EEXIST if the target already exists" do
|
|
|
|
File.link(@file, @link)
|
2019-07-27 12:40:09 +02:00
|
|
|
-> { File.link(@file, @link) }.should raise_error(Errno::EEXIST)
|
2017-05-07 12:04:49 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it "raises an ArgumentError if not passed two arguments" do
|
2019-07-27 12:40:09 +02:00
|
|
|
-> { File.link }.should raise_error(ArgumentError)
|
|
|
|
-> { File.link(@file) }.should raise_error(ArgumentError)
|
|
|
|
-> { File.link(@file, @link, @file) }.should raise_error(ArgumentError)
|
2017-05-07 12:04:49 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it "raises a TypeError if not passed String types" do
|
2019-07-27 12:40:09 +02:00
|
|
|
-> { File.link(@file, nil) }.should raise_error(TypeError)
|
|
|
|
-> { File.link(@file, 1) }.should raise_error(TypeError)
|
2017-05-07 12:04:49 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|