Skip to content
Browse files

rake_task now capable of loading specs with single and double quotes …

…in path

- Closes #247.
  • Loading branch information...
1 parent fda0549 commit 0327687028ff1e9e7b629cdc9807b77b11bd40b7 @janmejay janmejay committed with dchelimsky
Showing with 33 additions and 1 deletion.
  1. +1 −1 lib/rspec/core/rake_task.rb
  2. +32 −0 spec/rspec/core/rake_task_spec.rb
View
2 lib/rspec/core/rake_task.rb
@@ -149,7 +149,7 @@ def files_to_run # :nodoc:
if ENV['SPEC']
FileList[ ENV['SPEC'] ]
else
- FileList[ pattern ].map { |f| %["#{f}"] }
+ FileList[ pattern ].map { |f| f.gsub(/"/, '\"').gsub(/'/, "\\\\'") }
end
end
View
32 spec/rspec/core/rake_task_spec.rb
@@ -136,5 +136,37 @@ def spec_command
task.__send__(:files_to_run).should eq(["path/to/file"])
end
end
+
+ context "with pattern matching files with quotes" do
+ before do
+ @tmp_dir = File.expand_path(File.join(File.dirname(__FILE__), "rake_task_tmp_dir"))
+ @task = RakeTask.new do |t|
+ t.pattern = File.join(@tmp_dir, "*.rb")
+ end
+ FileUtils.mkdir_p @tmp_dir
+ spec_file_content = <<-END
+describe "spec" do
+ it "should pass" do
+ 1.should == 1
+ end
+end
+END
+ ["first_file.rb", "second_\"file.rb", "third_'file.rb"].each do |file_name|
+ File.open(File.join(@tmp_dir, file_name), "w") do |h|
+ h.write spec_file_content
+ end
+ end
+ end
+
+ after do
+ FileUtils.rm_rf @tmp_dir
+ end
+
+ it "sets files to run" do
+ `/usr/bin/env ruby #{@task.send(:spec_command)}`
+ $?.exitstatus.should == 0
+ #@task.send(:files_to_run).should eq([])
+ end
+ end
end
end

0 comments on commit 0327687

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