From 4d3b610afde1e339fde0380ae803c490fe94cc97 Mon Sep 17 00:00:00 2001 From: Andy Lindeman Date: Sat, 15 Sep 2012 18:57:51 -0400 Subject: [PATCH] Quotes ruby command in case it contains spaces * Closes #674 --- Changelog.md | 1 + lib/autotest/rspec2.rb | 2 +- spec/autotest/rspec_spec.rb | 7 ++++++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Changelog.md b/Changelog.md index 071333aa6e..a879f9bf59 100644 --- a/Changelog.md +++ b/Changelog.md @@ -8,6 +8,7 @@ Enhancements * JSON Formatter (Alex Chaffee) * Refactor rake task internals (Sam Phippen) * Refactor HtmlFormatter (Pete Hodgson) +* Autotest supports a path to Ruby that contains spaces (dsisnero) Bug fixes diff --git a/lib/autotest/rspec2.rb b/lib/autotest/rspec2.rb index 50d07f6c1c..70a301f295 100644 --- a/lib/autotest/rspec2.rb +++ b/lib/autotest/rspec2.rb @@ -47,7 +47,7 @@ def consolidate_failures(failed) # Overrides Autotest's implementation to generate the rspec command to run def make_test_cmd(files_to_test) files_to_test.empty? ? '' : - "#{prefix}#{ruby}#{suffix} -S '#{RSPEC_EXECUTABLE}' --tty #{normalize(files_to_test).keys.flatten.map { |f| "'#{f}'"}.join(' ')}" + "#{prefix}'#{ruby}'#{suffix} -S '#{RSPEC_EXECUTABLE}' --tty #{normalize(files_to_test).keys.flatten.map { |f| "'#{f}'"}.join(' ')}" end # Generates a map of filenames to Arrays for Autotest diff --git a/spec/autotest/rspec_spec.rb b/spec/autotest/rspec_spec.rb index 69d4be262a..3db337670f 100644 --- a/spec/autotest/rspec_spec.rb +++ b/spec/autotest/rspec_spec.rb @@ -3,7 +3,7 @@ describe Autotest::Rspec2 do let(:rspec_autotest) { Autotest::Rspec2.new } let(:spec_cmd) { File.expand_path("../../../exe/rspec", __FILE__) } - let(:ruby_cmd) { "ruby" } + let(:ruby_cmd) { "/path/to/ruby" } before do File.stub(:exist?) { false } @@ -50,6 +50,11 @@ end end + it "quotes the path of the ruby executable" do + cmd = rspec_autotest.make_test_cmd(@files_to_test) + cmd.should match(%r('/path/to/ruby')) + end + it "gives '--tty' to #{Autotest::Rspec2::RSPEC_EXECUTABLE}, not '--autotest'" do cmd = rspec_autotest.make_test_cmd(@files_to_test) cmd.should match(' --tty ')