Skip to content
Browse files

fix pattern escaping of spaces

  • Loading branch information...
1 parent 2901dd0 commit 7007f75e98358dd1e8ca8953fa35e378efd0fef3 @ruggeri ruggeri committed Nov 4, 2012
Showing with 5 additions and 4 deletions.
  1. +1 −1 lib/rspec/core/rake_task.rb
  2. +4 −3 spec/rspec/core/rake_task_spec.rb
View
2 lib/rspec/core/rake_task.rb
@@ -161,7 +161,7 @@ def files_to_run
if ENV['SPEC']
FileList[ ENV['SPEC'] ].sort
else
- FileList[ pattern ].sort.map { |f| f.gsub(/"/, '\"').gsub(/'/, "\\\\'") }
+ FileList[ pattern ].sort.map { |f| f.shellescape }
end
end
View
7 spec/rspec/core/rake_task_spec.rb
@@ -139,14 +139,15 @@ def specify_consistent_ordering_of_files_to_run(pattern, task)
specify_consistent_ordering_of_files_to_run('a/*.rb', task)
end
- context "with paths with quotes" do
- it "escapes the quotes" do
+ context "with paths with quotes or spaces" do
+ it "escapes the quotes and spaces" do
task.pattern = File.join(Dir.tmpdir, "*spec.rb")
- ["first_spec.rb", "second_\"spec.rb", "third_\'spec.rb"].each do |file_name|
+ ["first_spec.rb", "second_\"spec.rb", "third_\'spec.rb", "fourth spec.rb"].each do |file_name|
FileUtils.touch(File.join(Dir.tmpdir, file_name))
end
task.__send__(:files_to_run).sort.should eq([
File.join(Dir.tmpdir, "first_spec.rb"),
+ File.join(Dir.tmpdir, "fourth\\ spec.rb"),
File.join(Dir.tmpdir, "second_\\\"spec.rb"),
File.join(Dir.tmpdir, "third_\\\'spec.rb")
])

0 comments on commit 7007f75

Please sign in to comment.
Something went wrong with that request. Please try again.