2018-03-04 10:09:32 -05:00
|
|
|
require_relative '../../spec_helper'
|
2017-05-07 08:04:49 -04:00
|
|
|
require 'pathname'
|
|
|
|
|
|
|
|
describe "Pathname.new" do
|
|
|
|
it "returns a new Pathname Object with 1 argument" do
|
|
|
|
Pathname.new('').should be_kind_of(Pathname)
|
|
|
|
end
|
|
|
|
|
|
|
|
it "raises an ArgumentError when called with \0" do
|
2019-07-27 06:40:09 -04:00
|
|
|
-> { Pathname.new("\0")}.should raise_error(ArgumentError)
|
2017-05-07 08:04:49 -04:00
|
|
|
end
|
|
|
|
|
2019-09-24 23:59:12 -04:00
|
|
|
ruby_version_is ''...'2.7' do
|
|
|
|
it "is tainted if path is tainted" do
|
|
|
|
path = '/usr/local/bin'.taint
|
2020-05-03 06:28:29 -04:00
|
|
|
Pathname.new(path).should.tainted?
|
2019-09-24 23:59:12 -04:00
|
|
|
end
|
2017-05-07 08:04:49 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it "raises a TypeError if not passed a String type" do
|
2019-07-27 06:40:09 -04:00
|
|
|
-> { Pathname.new(nil) }.should raise_error(TypeError)
|
|
|
|
-> { Pathname.new(0) }.should raise_error(TypeError)
|
|
|
|
-> { Pathname.new(true) }.should raise_error(TypeError)
|
|
|
|
-> { Pathname.new(false) }.should raise_error(TypeError)
|
2017-05-07 08:04:49 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it "initializes with an object with to_path" do
|
|
|
|
Pathname.new(mock_to_path('foo')).should == Pathname.new('foo')
|
|
|
|
end
|
|
|
|
end
|