From daff249519ee89ec56c604e5f808c9d3ea57026e Mon Sep 17 00:00:00 2001 From: Earlopain <14981592+Earlopain@users.noreply.github.com> Date: Sat, 27 Jun 2026 11:49:30 +0200 Subject: [PATCH] Add spec for multiple -r and from both CLI and RUBYOPT --- command_line/dash_r_spec.rb | 5 +++++ command_line/rubyopt_spec.rb | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/command_line/dash_r_spec.rb b/command_line/dash_r_spec.rb index 0de9ba2e24..052ad5e638 100644 --- a/command_line/dash_r_spec.rb +++ b/command_line/dash_r_spec.rb @@ -25,4 +25,9 @@ out.should_not.include?("REQUIRED") out.should.include?("No such file or directory") end + + it "requires in order when given multiple times" do + ruby_exe("", options: "-r#{fixture(__FILE__, "test_file.rb")} -r#{fixture(__FILE__, "verbose.rb")}"). + should == "REQUIRED\nfalse\n" + end end diff --git a/command_line/rubyopt_spec.rb b/command_line/rubyopt_spec.rb index eb297cd6fe..7ac8757749 100644 --- a/command_line/rubyopt_spec.rb +++ b/command_line/rubyopt_spec.rb @@ -83,6 +83,12 @@ ruby_exe("0", args: '2>&1').should =~ /^rubyopt.rb required/ end + it "requires from CLI -r first and then from RUBYOPT -r" do + ENV["RUBYOPT"] = "-r#{fixture(__FILE__, "rubyopt.rb")}" + ruby_exe("", options: "-r#{fixture(__FILE__, "test_file.rb")}"). + should == "REQUIRED\nrubyopt.rb required\n" + end + it "raises a RuntimeError for '-a'" do ENV["RUBYOPT"] = '-a' ruby_exe("", args: '2>&1', exit_status: 1).should =~ /RuntimeError/