1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185
|
require_relative '../spec_helper'
describe "Processing RUBYOPT" do
before :each do
@rubyopt, ENV["RUBYOPT"] = ENV["RUBYOPT"], nil
end
after :each do
ENV["RUBYOPT"] = @rubyopt
end
it "adds the -I path to $LOAD_PATH" do
ENV["RUBYOPT"] = "-Ioptrubyspecincl"
result = ruby_exe("puts $LOAD_PATH.grep(/byspecin/)")
result.chomp[-15..-1].should == "optrubyspecincl"
end
it "sets $DEBUG to true for '-d'" do
ENV["RUBYOPT"] = '-d'
command = %[puts "value of $DEBUG is \#{$DEBUG}"]
result = ruby_exe(command, args: "2>&1")
result.should =~ /value of \$DEBUG is true/
end
guard -> { not CROSS_COMPILING } do
it "prints the version number for '-v'" do
ENV["RUBYOPT"] = '-v'
ruby_exe("")[/\A.*/].should == RUBY_DESCRIPTION
end
it "ignores whitespace around the option" do
ENV["RUBYOPT"] = ' -v '
ruby_exe("")[/\A.*/].should == RUBY_DESCRIPTION
end
end
it "sets $VERBOSE to true for '-w'" do
ENV["RUBYOPT"] = '-w'
ruby_exe("p $VERBOSE").chomp.should == "true"
end
it "sets $VERBOSE to true for '-W'" do
ENV["RUBYOPT"] = '-W'
ruby_exe("p $VERBOSE").chomp.should == "true"
end
it "sets $VERBOSE to nil for '-W0'" do
ENV["RUBYOPT"] = '-W0'
ruby_exe("p $VERBOSE").chomp.should == "nil"
end
it "sets $VERBOSE to false for '-W1'" do
ENV["RUBYOPT"] = '-W1'
ruby_exe("p $VERBOSE").chomp.should == "false"
end
it "sets $VERBOSE to true for '-W2'" do
ENV["RUBYOPT"] = '-W2'
ruby_exe("p $VERBOSE").chomp.should == "true"
end
it "suppresses deprecation warnings for '-W:no-deprecated'" do
ENV["RUBYOPT"] = '-W:no-deprecated'
result = ruby_exe('$; = ""', args: '2>&1')
result.should == ""
end
it "suppresses experimental warnings for '-W:no-experimental'" do
ENV["RUBYOPT"] = '-W:no-experimental'
result = ruby_exe('case 0; in a; end', args: '2>&1')
result.should == ""
end
it "suppresses deprecation and experimental warnings for '-W:no-deprecated -W:no-experimental'" do
ENV["RUBYOPT"] = '-W:no-deprecated -W:no-experimental'
result = ruby_exe('case ($; = ""); in a; end', args: '2>&1')
result.should == ""
end
it "requires the file for '-r'" do
f = fixture __FILE__, "rubyopt"
ENV["RUBYOPT"] = "-r#{f}"
ruby_exe("0", args: '2>&1').should =~ /^rubyopt.rb required/
end
it "raises a RuntimeError for '-a'" do
ENV["RUBYOPT"] = '-a'
ruby_exe("", args: '2>&1', exit_status: 1).should =~ /RuntimeError/
end
it "raises a RuntimeError for '-p'" do
ENV["RUBYOPT"] = '-p'
ruby_exe("", args: '2>&1', exit_status: 1).should =~ /RuntimeError/
end
it "raises a RuntimeError for '-n'" do
ENV["RUBYOPT"] = '-n'
ruby_exe("", args: '2>&1', exit_status: 1).should =~ /RuntimeError/
end
it "raises a RuntimeError for '-y'" do
ENV["RUBYOPT"] = '-y'
ruby_exe("", args: '2>&1', exit_status: 1).should =~ /RuntimeError/
end
it "raises a RuntimeError for '-c'" do
ENV["RUBYOPT"] = '-c'
ruby_exe("", args: '2>&1', exit_status: 1).should =~ /RuntimeError/
end
it "raises a RuntimeError for '-s'" do
ENV["RUBYOPT"] = '-s'
ruby_exe("", args: '2>&1', exit_status: 1).should =~ /RuntimeError/
end
it "raises a RuntimeError for '-h'" do
ENV["RUBYOPT"] = '-h'
ruby_exe("", args: '2>&1', exit_status: 1).should =~ /RuntimeError/
end
it "raises a RuntimeError for '--help'" do
ENV["RUBYOPT"] = '--help'
ruby_exe("", args: '2>&1', exit_status: 1).should =~ /RuntimeError/
end
it "raises a RuntimeError for '-l'" do
ENV["RUBYOPT"] = '-l'
ruby_exe("", args: '2>&1', exit_status: 1).should =~ /RuntimeError/
end
it "raises a RuntimeError for '-S'" do
ENV["RUBYOPT"] = '-S irb'
ruby_exe("", args: '2>&1', exit_status: 1).should =~ /RuntimeError/
end
it "raises a RuntimeError for '-e'" do
ENV["RUBYOPT"] = '-e0'
ruby_exe("", args: '2>&1', exit_status: 1).should =~ /RuntimeError/
end
it "raises a RuntimeError for '-i'" do
ENV["RUBYOPT"] = '-i.bak'
ruby_exe("", args: '2>&1', exit_status: 1).should =~ /RuntimeError/
end
it "raises a RuntimeError for '-x'" do
ENV["RUBYOPT"] = '-x'
ruby_exe("", args: '2>&1', exit_status: 1).should =~ /RuntimeError/
end
it "raises a RuntimeError for '-C'" do
ENV["RUBYOPT"] = '-C'
ruby_exe("", args: '2>&1', exit_status: 1).should =~ /RuntimeError/
end
it "raises a RuntimeError for '-X'" do
ENV["RUBYOPT"] = '-X.'
ruby_exe("", args: '2>&1', exit_status: 1).should =~ /RuntimeError/
end
it "raises a RuntimeError for '-F'" do
ENV["RUBYOPT"] = '-F'
ruby_exe("", args: '2>&1', exit_status: 1).should =~ /RuntimeError/
end
it "raises a RuntimeError for '-0'" do
ENV["RUBYOPT"] = '-0'
ruby_exe("", args: '2>&1', exit_status: 1).should =~ /RuntimeError/
end
it "raises a RuntimeError for '--copyright'" do
ENV["RUBYOPT"] = '--copyright'
ruby_exe("", args: '2>&1', exit_status: 1).should =~ /RuntimeError/
end
it "raises a RuntimeError for '--version'" do
ENV["RUBYOPT"] = '--version'
ruby_exe("", args: '2>&1', exit_status: 1).should =~ /RuntimeError/
end
it "raises a RuntimeError for '--yydebug'" do
ENV["RUBYOPT"] = '--yydebug'
ruby_exe("", args: '2>&1', exit_status: 1).should =~ /RuntimeError/
end
end
|