Skip to content

Commit 0d5201b

Browse files
committed
Should not hardcode ruby name
1 parent 8d393f4 commit 0d5201b

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

spec/integration/ruby_command_line_spec.rb

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
require_relative "../spec_helper"
44

55
module SyntaxSuggest
6+
ruby = ENV.fetch("RUBY", "ruby")
67
RSpec.describe "Requires with ruby cli" do
78
it "namespaces all monkeypatched methods" do
89
Dir.mktmpdir do |dir|
@@ -16,9 +17,9 @@ module SyntaxSuggest
1617
api_only_methods_file = tmpdir.join("api_only_methods.txt")
1718
kernel_methods_file = tmpdir.join("kernel_methods.txt")
1819

19-
d_pid = Process.spawn("ruby -I#{lib_dir} -rsyntax_suggest #{script} 2>&1 > #{syntax_suggest_methods_file}")
20-
k_pid = Process.spawn("ruby #{script} 2>&1 >> #{kernel_methods_file}")
21-
r_pid = Process.spawn("ruby -I#{lib_dir} -rsyntax_suggest/api #{script} 2>&1 > #{api_only_methods_file}")
20+
d_pid = Process.spawn("#{ruby} -I#{lib_dir} -rsyntax_suggest #{script} 2>&1 > #{syntax_suggest_methods_file}")
21+
k_pid = Process.spawn("#{ruby} #{script} 2>&1 >> #{kernel_methods_file}")
22+
r_pid = Process.spawn("#{ruby} -I#{lib_dir} -rsyntax_suggest/api #{script} 2>&1 > #{api_only_methods_file}")
2223

2324
Process.wait(k_pid)
2425
Process.wait(d_pid)
@@ -69,7 +70,7 @@ module SyntaxSuggest
6970
load "#{script.expand_path}"
7071
EOM
7172

72-
out = `ruby -I#{lib_dir} -rsyntax_suggest #{require_rb} 2>&1`
73+
out = `#{ruby} -I#{lib_dir} -rsyntax_suggest #{require_rb} 2>&1`
7374

7475
expect($?.success?).to be_falsey
7576
expect(out).to include('> 5 it "flerg"').once
@@ -80,7 +81,7 @@ module SyntaxSuggest
8081
skip if ruby_core?
8182
skip if Gem::Version.new(RUBY_VERSION) < Gem::Version.new("3.2")
8283

83-
out = `ruby -I#{lib_dir} -rsyntax_suggest -e "puts SyntaxError.instance_method(:detailed_message).source_location" 2>&1`
84+
out = `#{ruby} -I#{lib_dir} -rsyntax_suggest -e "puts SyntaxError.instance_method(:detailed_message).source_location" 2>&1`
8485

8586
expect($?.success?).to be_truthy
8687
expect(out).to include(lib_dir.join("syntax_suggest").join("core_ext.rb").to_s).once
@@ -106,7 +107,7 @@ module SyntaxSuggest
106107
end
107108
EOM
108109

109-
out = `ruby -I#{lib_dir} -rsyntax_suggest #{script} 2>&1`
110+
out = `#{ruby} -I#{lib_dir} -rsyntax_suggest #{script} 2>&1`
110111

111112
expect($?.success?).to be_falsey
112113
expect(out).to include('> 5 it "flerg"').once
@@ -133,7 +134,7 @@ class Dog
133134
load "#{script.expand_path}"
134135
EOM
135136

136-
out = `ruby -I#{lib_dir} -rsyntax_suggest #{require_rb} 2>&1`
137+
out = `#{ruby} -I#{lib_dir} -rsyntax_suggest #{require_rb} 2>&1`
137138

138139
expect($?.success?).to be_truthy
139140
expect(out).to include("SyntaxSuggest is NOT loaded").once
@@ -149,7 +150,7 @@ class Dog
149150
eval("def lol")
150151
EOM
151152

152-
out = `ruby -I#{lib_dir} -rsyntax_suggest #{script} 2>&1`
153+
out = `#{ruby} -I#{lib_dir} -rsyntax_suggest #{script} 2>&1`
153154

154155
expect($?.success?).to be_falsey
155156
expect(out).to include("(eval):1")
@@ -167,7 +168,7 @@ class Dog
167168
break
168169
EOM
169170

170-
out = `ruby -I#{lib_dir} -rsyntax_suggest -e "require_relative '#{script}'" 2>&1`
171+
out = `#{ruby} -I#{lib_dir} -rsyntax_suggest -e "require_relative '#{script}'" 2>&1`
171172

172173
expect($?.success?).to be_falsey
173174
expect(out.downcase).to_not include("syntax ok")

0 commit comments

Comments
 (0)