diff options
Diffstat (limited to 'spec/ruby/command_line/feature_spec.rb')
-rw-r--r-- | spec/ruby/command_line/feature_spec.rb | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/spec/ruby/command_line/feature_spec.rb b/spec/ruby/command_line/feature_spec.rb index 16e106b37d..1a9ea925c9 100644 --- a/spec/ruby/command_line/feature_spec.rb +++ b/spec/ruby/command_line/feature_spec.rb @@ -1,6 +1,12 @@ require_relative '../spec_helper' describe "The --enable and --disable flags" do + before :all do + # Since some specs disable reading RUBYOPT, we instead pass its contents as :options for those specs + rubyopt = [ENV["RUBYOPT"]] + rubyopt << ENV["#{RUBY_ENGINE.upcase}OPT"] unless RUBY_ENGINE == 'ruby' + @rubyopt = RUBY_ENGINE == "ruby" ? "" : rubyopt.compact.join(" ") + end it "can be used with gems" do ruby_exe("p defined?(Gem)", options: "--enable=gems").chomp.should == "\"constant\"" @@ -25,9 +31,9 @@ describe "The --enable and --disable flags" do it "can be used with rubyopt" do ruby_exe("p $VERBOSE", options: "--enable=rubyopt", env: {'RUBYOPT' => '-w'}).chomp.should == "true" - ruby_exe("p $VERBOSE", options: "--disable=rubyopt", env: {'RUBYOPT' => '-w'}).chomp.should == "false" + ruby_exe("p $VERBOSE", options: "#{@rubyopt} --disable=rubyopt", env: {'RUBYOPT' => '-w'}).chomp.should == "false" ruby_exe("p $VERBOSE", options: "--enable-rubyopt", env: {'RUBYOPT' => '-w'}).chomp.should == "true" - ruby_exe("p $VERBOSE", options: "--disable-rubyopt", env: {'RUBYOPT' => '-w'}).chomp.should == "false" + ruby_exe("p $VERBOSE", options: "#{@rubyopt} --disable-rubyopt", env: {'RUBYOPT' => '-w'}).chomp.should == "false" end it "can be used with frozen-string-literal" do @@ -49,8 +55,8 @@ describe "The --enable and --disable flags" do it "can be used with all for disable" do e = "p [defined?(Gem), defined?(DidYouMean), $VERBOSE, 'foo'.frozen?]" env = {'RUBYOPT' => '-w'} - ruby_exe(e, options: "--disable=all", env: env).chomp.should == "[nil, nil, false, false]" - ruby_exe(e, options: "--disable-all", env: env).chomp.should == "[nil, nil, false, false]" + ruby_exe(e, options: "#{@rubyopt} --disable=all", env: env).chomp.should == "[nil, nil, false, false]" + ruby_exe(e, options: "#{@rubyopt} --disable-all", env: env).chomp.should == "[nil, nil, false, false]" end it "prints a warning for unknown features" do |