Guest User

Untitled

a guest
Jul 17th, 2018
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.07 KB | None | 0 0
  1. From 52859e4f013512157ab86cea4e89df5b651af88d Mon Sep 17 00:00:00 2001
  2. From: Janmejay Singh <singh.janmejay@gmail.com>
  3. Date: Tue, 14 Dec 2010 20:37:51 +0530
  4. Subject: [PATCH] rake_task now capable of loading specs with single and double quotes in path
  5.  
  6. ---
  7. lib/rspec/core/rake_task.rb | 2 +-
  8. spec/rspec/core/rake_task_spec.rb | 32 ++++++++++++++++++++++++++++++++
  9. 2 files changed, 33 insertions(+), 1 deletions(-)
  10.  
  11. diff --git a/lib/rspec/core/rake_task.rb b/lib/rspec/core/rake_task.rb
  12. index ad2da9d..0d576b2 100644
  13. --- a/lib/rspec/core/rake_task.rb
  14. +++ b/lib/rspec/core/rake_task.rb
  15. @@ -149,7 +149,7 @@ module RSpec
  16. if ENV['SPEC']
  17. FileList[ ENV['SPEC'] ]
  18. else
  19. - FileList[ pattern ].map { |f| %["#{f}"] }
  20. + FileList[ pattern ].map { |f| f.gsub(/"/, '\"').gsub(/'/, "\\\\'") }
  21. end
  22. end
  23.  
  24. diff --git a/spec/rspec/core/rake_task_spec.rb b/spec/rspec/core/rake_task_spec.rb
  25. index 97d9f66..e240a40 100644
  26. --- a/spec/rspec/core/rake_task_spec.rb
  27. +++ b/spec/rspec/core/rake_task_spec.rb
  28. @@ -136,5 +136,37 @@ module RSpec::Core
  29. task.__send__(:files_to_run).should eq(["path/to/file"])
  30. end
  31. end
  32. +
  33. + context "with pattern matching files with quotes" do
  34. + before do
  35. + @tmp_dir = File.expand_path(File.join(File.dirname(__FILE__), "rake_task_tmp_dir"))
  36. + @task = RakeTask.new do |t|
  37. + t.pattern = File.join(@tmp_dir, "*.rb")
  38. + end
  39. + FileUtils.mkdir_p @tmp_dir
  40. + spec_file_content = <<-END
  41. +describe "spec" do
  42. + it "should pass" do
  43. + 1.should == 1
  44. + end
  45. +end
  46. +END
  47. + ["first_file.rb", "second_\"file.rb", "third_'file.rb"].each do |file_name|
  48. + File.open(File.join(@tmp_dir, file_name), "w") do |h|
  49. + h.write spec_file_content
  50. + end
  51. + end
  52. + end
  53. +
  54. + after do
  55. + FileUtils.rm_rf @tmp_dir
  56. + end
  57. +
  58. + it "sets files to run" do
  59. + `/usr/bin/env ruby #{@task.send(:spec_command)}`
  60. + $?.exitstatus.should == 0
  61. + #@task.send(:files_to_run).should eq([])
  62. + end
  63. + end
  64. end
  65. end
  66. --
  67. 1.7.2.2
Add Comment
Please, Sign In to add comment