2018-03-04 10:09:32 -05:00
|
|
|
require_relative '../spec_helper'
|
2017-05-07 08:04:49 -04:00
|
|
|
|
|
|
|
describe "The -I command line option" do
|
|
|
|
before :each do
|
|
|
|
@script = fixture __FILE__, "loadpath.rb"
|
|
|
|
end
|
|
|
|
|
|
|
|
it "adds the path to the load path ($:)" do
|
|
|
|
ruby_exe(@script, options: "-I fixtures").should include("fixtures")
|
|
|
|
end
|
2018-04-28 15:50:06 -04:00
|
|
|
|
|
|
|
it "adds the path at the front of $LOAD_PATH" do
|
|
|
|
lines = ruby_exe(@script, options: "-I fixtures").lines
|
2018-04-28 19:04:56 -04:00
|
|
|
if PlatformGuard.implementation? :ruby
|
2018-04-28 15:50:06 -04:00
|
|
|
# In a MRI checkout, $PWD ends up as the first entry in $LOAD_PATH.
|
|
|
|
# So just assert that it's at the beginning.
|
|
|
|
idx = lines.index { |l| l.include?("fixtures") }
|
|
|
|
idx.should < 2
|
|
|
|
idx.should < lines.size-1
|
|
|
|
else
|
|
|
|
lines[0].should include("fixtures")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it "adds the path expanded from CWD to $LOAD_PATH" do
|
|
|
|
ruby_exe(@script, options: "-I fixtures").lines.should include "#{Dir.pwd}/fixtures\n"
|
|
|
|
end
|
|
|
|
|
|
|
|
it "expands a path from CWD even if it does not exist" do
|
|
|
|
ruby_exe(@script, options: "-I not_exist/not_exist").lines.should include "#{Dir.pwd}/not_exist/not_exist\n"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-04-29 09:45:11 -04:00
|
|
|
platform_is_not :windows do
|
|
|
|
describe "The -I command line option" do
|
|
|
|
before :each do
|
|
|
|
@script = fixture __FILE__, "loadpath.rb"
|
|
|
|
@fixtures = File.dirname(@script)
|
|
|
|
@symlink = tmp("loadpath_symlink")
|
|
|
|
File.symlink(@fixtures, @symlink)
|
|
|
|
end
|
2018-04-28 15:50:06 -04:00
|
|
|
|
2018-04-29 09:45:11 -04:00
|
|
|
after :each do
|
|
|
|
rm_r @symlink
|
|
|
|
end
|
2018-04-28 15:50:06 -04:00
|
|
|
|
2018-04-29 09:45:11 -04:00
|
|
|
it "does not expand symlinks" do
|
|
|
|
ruby_exe(@script, options: "-I #{@symlink}").lines.should include "#{@symlink}\n"
|
|
|
|
end
|
2018-04-28 15:50:06 -04:00
|
|
|
end
|
2017-05-07 08:04:49 -04:00
|
|
|
end
|