From 01218db8d43fab939fe5b53738af1fab771373dd Mon Sep 17 00:00:00 2001
From: Michael Grosser <michael@grosser.it>
Date: Fri, 17 Sep 2021 15:57:25 -0700
Subject: [PATCH] allow running test files with multiple spaces (#832)

---
 lib/parallel_tests/test/runner.rb | 2 +-
 spec/integration_spec.rb          | 6 ++++++
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/lib/parallel_tests/test/runner.rb b/lib/parallel_tests/test/runner.rb
index 5b34ae21..67283dfb 100644
--- a/lib/parallel_tests/test/runner.rb
+++ b/lib/parallel_tests/test/runner.rb
@@ -24,7 +24,7 @@ def test_file_name
         end
 
         def run_tests(test_files, process_number, num_processes, options)
-          require_list = test_files.map { |file| file.sub(" ", "\\ ") }.join(" ")
+          require_list = test_files.map { |file| file.gsub(" ", "\\ ") }.join(" ")
           cmd = "#{executable} -Itest -e '%w[#{require_list}].each { |f| require %{./\#{f}} }' -- #{options[:test_options]}"
           execute_command(cmd, process_number, num_processes, options)
         end
diff --git a/spec/integration_spec.rb b/spec/integration_spec.rb
index d4bc3d03..b5c13608 100644
--- a/spec/integration_spec.rb
+++ b/spec/integration_spec.rb
@@ -465,6 +465,12 @@ def test_unicode
     )
   end
 
+  it "can run with uncommon file names" do
+    skip if RUBY_PLATFORM == "java" # just too slow ...
+    write "test/long ( stuff ) _test.rb", "puts 'hey'"
+    expect(run_tests("test", processes: 2)).to include("hey")
+  end
+
   context "RSpec" do
     it_runs_the_default_folder_if_it_exists "rspec", "spec"