Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Expand the path portion of ruby_exe_options

This allows ruby_exe's :dir option to be used on Rubinius,
where ruby_exe_options returns a relative path.
  • Loading branch information...
commit d44cd594c7d1897b25ba74ea376b30438f71417a 1 parent 445aec9
@jfirebaugh jfirebaugh authored
Showing with 20 additions and 2 deletions.
  1. +2 −2 lib/mspec/helpers/ruby_exe.rb
  2. +18 −0 spec/helpers/ruby_exe_spec.rb
View
4 lib/mspec/helpers/ruby_exe.rb
@@ -102,13 +102,13 @@ def ruby_exe_options(option)
def resolve_ruby_exe
[:env, :engine, :name, :install_name].each do |option|
next unless cmd = ruby_exe_options(option)
- exe = cmd.split.first
+ exe, *rest = cmd.split(" ")
# It has been reported that File.executable is not reliable
# on Windows platforms (see commit 56bc555c). So, we check the
# platform.
if File.exists?(exe) and (PlatformGuard.windows? or File.executable?(exe))
- return cmd
+ return [File.expand_path(exe), *rest].join(" ")
end
end
nil
View
18 spec/helpers/ruby_exe_spec.rb
@@ -105,6 +105,7 @@ class RubyExeSpecs
@script.should_receive(:ruby_exe_options).and_return(@name)
File.should_receive(:exists?).with(@name).and_return(true)
File.should_receive(:executable?).with(@name).and_return(true)
+ File.should_receive(:expand_path).with(@name).and_return(@name)
@script.resolve_ruby_exe.should == @name
end
@@ -113,9 +114,19 @@ class RubyExeSpecs
@script.should_receive(:ruby_exe_options).and_return(@name)
File.should_receive(:exists?).with(@name).and_return(true)
File.should_not_receive(:executable?)
+ File.should_receive(:expand_path).with(@name).and_return(@name)
@script.resolve_ruby_exe.should == @name
end
+ it "expands the path portion of the result of #ruby_exe_options" do
+ PlatformGuard.stub!(:windows?).and_return(false)
+ @script.should_receive(:ruby_exe_options).and_return("#{@name} -Xfoo")
+ File.should_receive(:exists?).with(@name).and_return(true)
+ File.should_receive(:executable?).with(@name).and_return(true)
+ File.should_receive(:expand_path).with(@name).and_return("/usr/bin/#{@name}")
+ @script.resolve_ruby_exe.should == "/usr/bin/#{@name} -Xfoo"
+ end
+
it "returns nil if no exe is found" do
File.should_receive(:exists?).at_least(:once).and_return(false)
@script.resolve_ruby_exe.should be_nil
@@ -177,6 +188,13 @@ class RubyExeSpecs
@script.ruby_exe nil, :options => "-c", :args => "> file.txt"
end
+ describe "with :dir option" do
+ it "executes the command in the given working directory" do
+ Dir.should_receive(:chdir).with("tmp")
+ @script.ruby_exe nil, :dir => "tmp"
+ end
+ end
+
describe "with :env option" do
before :each do
@script.stub!(:`)
Please sign in to comment.
Something went wrong with that request. Please try again.