Skip to content

Commit

Permalink
Quotes ruby command in case it contains spaces
Browse files Browse the repository at this point in the history
* Closes rspec#674
  • Loading branch information
alindeman committed Sep 15, 2012
1 parent 410155e commit 4d3b610
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions Changelog.md
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion lib/autotest/rspec2.rb
Expand Up @@ -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
Expand Down
7 changes: 6 additions & 1 deletion spec/autotest/rspec_spec.rb
Expand Up @@ -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 }
Expand Down Expand Up @@ -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 ')
Expand Down

0 comments on commit 4d3b610

Please sign in to comment.