summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authoreregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-05-10 14:35:24 +0000
committereregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-05-10 14:35:24 +0000
commitd655f8c592bc5355cad2216cdca8a52d4f8aea6d (patch)
tree4ac870e83b79da5b5db859e854991e39f74d3b26 /spec
parent849bf24abff3a7e02b7ed4ebe3f3810dc8820040 (diff)
Use ruby_cmd instead of the RUBY_EXE constant in specs
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58653 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'spec')
-rw-r--r--spec/rubyspec/core/io/popen_spec.rb26
-rw-r--r--spec/rubyspec/core/kernel/fixtures/classes.rb10
2 files changed, 17 insertions, 19 deletions
diff --git a/spec/rubyspec/core/io/popen_spec.rb b/spec/rubyspec/core/io/popen_spec.rb
index 0619136320..84a13f0a7f 100644
--- a/spec/rubyspec/core/io/popen_spec.rb
+++ b/spec/rubyspec/core/io/popen_spec.rb
@@ -1,8 +1,6 @@
require File.expand_path('../../../spec_helper', __FILE__)
require File.expand_path('../fixtures/classes', __FILE__)
-ruby_exe = RUBY_EXE.split
-
describe "IO.popen" do
before :each do
@io = nil
@@ -199,28 +197,28 @@ describe "IO.popen" do
end
it "accepts an Array of command and arguments" do
- exe, *args = *ruby_exe
+ exe, *args = ruby_cmd(nil).split
IO.popen({"FOO" => "bar"}, [[exe, "specfu"], *args, "-e", "puts ENV['FOO']"]) do |io|
io.read.should == "bar\n"
end
end
it "accepts an Array of command and arguments, and an IO mode" do
- exe, *args = *ruby_exe
+ exe, *args = ruby_cmd(nil).split
IO.popen({"FOO" => "bar"}, [[exe, "specfu"], *args, "-e", "puts ENV['FOO']"], "r") do |io|
io.read.should == "bar\n"
end
end
it "accepts an Array command with a separate trailing Hash of Process.exec options" do
- IO.popen({"FOO" => "bar"}, [*ruby_exe, "-e", "STDERR.puts ENV['FOO']"],
+ IO.popen({"FOO" => "bar"}, [*ruby_cmd(nil).split, "-e", "STDERR.puts ENV['FOO']"],
err: [:child, :out]) do |io|
io.read.should == "bar\n"
end
end
it "accepts an Array command with a separate trailing Hash of Process.exec options, and an IO mode" do
- IO.popen({"FOO" => "bar"}, [*ruby_exe, "-e", "STDERR.puts ENV['FOO']"],
+ IO.popen({"FOO" => "bar"}, [*ruby_cmd(nil).split, "-e", "STDERR.puts ENV['FOO']"],
"r", err: [:child, :out]) do |io|
io.read.should == "bar\n"
end
@@ -229,45 +227,45 @@ describe "IO.popen" do
context "with a leading Array argument" do
it "uses the Array as command plus args for the child process" do
- IO.popen([*ruby_exe, "-e", "puts 'hello'"]) do |io|
+ IO.popen([*ruby_cmd(nil).split, "-e", "puts 'hello'"]) do |io|
io.read.should == "hello\n"
end
end
it "accepts a leading ENV Hash" do
- IO.popen([{"FOO" => "bar"}, *ruby_exe, "-e", "puts ENV['FOO']"]) do |io|
+ IO.popen([{"FOO" => "bar"}, *ruby_cmd(nil).split, "-e", "puts ENV['FOO']"]) do |io|
io.read.should == "bar\n"
end
end
it "accepts a trailing Hash of Process.exec options" do
- IO.popen([*ruby_exe, "does_not_exist", {err: [:child, :out]}]) do |io|
+ IO.popen([*ruby_cmd(nil).split, "does_not_exist", {err: [:child, :out]}]) do |io|
io.read.should =~ /LoadError/
end
end
it "accepts an IO mode argument following the Array" do
- IO.popen([*ruby_exe, "does_not_exist", {err: [:child, :out]}], "r") do |io|
+ IO.popen([*ruby_cmd(nil).split, "does_not_exist", {err: [:child, :out]}], "r") do |io|
io.read.should =~ /LoadError/
end
end
it "accepts [env, command, arg1, arg2, ..., exec options]" do
- IO.popen([{"FOO" => "bar"}, *ruby_exe, "-e", "STDERR.puts ENV[:FOO.to_s]",
+ IO.popen([{"FOO" => "bar"}, *ruby_cmd(nil).split, "-e", "STDERR.puts ENV[:FOO.to_s]",
err: [:child, :out]]) do |io|
io.read.should == "bar\n"
end
end
it "accepts '[env, command, arg1, arg2, ..., exec options], mode'" do
- IO.popen([{"FOO" => "bar"}, *ruby_exe, "-e", "STDERR.puts ENV[:FOO.to_s]",
+ IO.popen([{"FOO" => "bar"}, *ruby_cmd(nil).split, "-e", "STDERR.puts ENV[:FOO.to_s]",
err: [:child, :out]], "r") do |io|
io.read.should == "bar\n"
end
end
it "accepts '[env, command, arg1, arg2, ..., exec options], mode, IO options'" do
- IO.popen([{"FOO" => "bar"}, *ruby_exe, "-e", "STDERR.puts ENV[:FOO.to_s]",
+ IO.popen([{"FOO" => "bar"}, *ruby_cmd(nil).split, "-e", "STDERR.puts ENV[:FOO.to_s]",
err: [:child, :out]], "r",
internal_encoding: Encoding::EUC_JP) do |io|
io.read.should == "bar\n"
@@ -276,7 +274,7 @@ describe "IO.popen" do
end
it "accepts '[env, command, arg1, arg2, ...], mode, IO + exec options'" do
- IO.popen([{"FOO" => "bar"}, *ruby_exe, "-e", "STDERR.puts ENV[:FOO.to_s]"], "r",
+ IO.popen([{"FOO" => "bar"}, *ruby_cmd(nil).split, "-e", "STDERR.puts ENV[:FOO.to_s]"], "r",
err: [:child, :out], internal_encoding: Encoding::EUC_JP) do |io|
io.read.should == "bar\n"
io.internal_encoding.should == Encoding::EUC_JP
diff --git a/spec/rubyspec/core/kernel/fixtures/classes.rb b/spec/rubyspec/core/kernel/fixtures/classes.rb
index 118b87fb8d..fa6d8baf0b 100644
--- a/spec/rubyspec/core/kernel/fixtures/classes.rb
+++ b/spec/rubyspec/core/kernel/fixtures/classes.rb
@@ -32,26 +32,26 @@ module KernelSpecs
end
def self.has_private_method(name)
- cmd = %[| #{RUBY_EXE} -n -e "print Kernel.private_method_defined?('#{name}')"]
+ cmd = %[| #{ruby_cmd(nil)} -n -e "print Kernel.private_method_defined?('#{name}')"]
ruby_exe("puts", args: cmd) == "true"
end
def self.chop(str, method)
- cmd = "| #{RUBY_EXE} -n -e '$_ = #{str.inspect}; #{method}; print $_'"
+ cmd = "| #{ruby_cmd(nil)} -n -e '$_ = #{str.inspect}; #{method}; print $_'"
ruby_exe "puts", args: cmd
end
def self.encoded_chop(file)
- ruby_exe "puts", args: "| #{RUBY_EXE} -n #{file}"
+ ruby_exe "puts", args: "| #{ruby_cmd(nil)} -n #{file}"
end
def self.chomp(str, method, sep="\n")
- cmd = "| #{RUBY_EXE} -n -e '$_ = #{str.inspect}; $/ = #{sep.inspect}; #{method}; print $_'"
+ cmd = "| #{ruby_cmd(nil)} -n -e '$_ = #{str.inspect}; $/ = #{sep.inspect}; #{method}; print $_'"
ruby_exe "puts", args: cmd
end
def self.encoded_chomp(file)
- ruby_exe "puts", args: "| #{RUBY_EXE} -n #{file}"
+ ruby_exe "puts", args: "| #{ruby_cmd(nil)} -n #{file}"
end
# kind_of?, is_a?, instance_of?