2018-03-04 10:09:32 -05:00
|
|
|
require_relative '../../spec_helper'
|
2017-05-07 08:04:49 -04: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 08:26:05 -04:00
|
|
|
platform_is_not :windows, :android do
|
2017-05-07 08:04:49 -04:00
|
|
|
it "link a file with another" do
|
|
|
|
File.link(@file, @link).should == 0
|
2019-09-29 13:13:37 -04:00
|
|
|
File.should.exist?(@link)
|
2017-05-07 08:04:49 -04: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 06:40:09 -04:00
|
|
|
-> { File.link(@file, @link) }.should raise_error(Errno::EEXIST)
|
2017-05-07 08:04:49 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it "raises an ArgumentError if not passed two arguments" do
|
2019-07-27 06:40:09 -04: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 08:04:49 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it "raises a TypeError if not passed String types" do
|
2019-07-27 06:40:09 -04:00
|
|
|
-> { File.link(@file, nil) }.should raise_error(TypeError)
|
|
|
|
-> { File.link(@file, 1) }.should raise_error(TypeError)
|
2017-05-07 08:04:49 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|