Allow other directories to be specified when accessing fixtures.

This commit is contained in:
Guo Xiang Tan 2016-08-18 16:34:11 +08:00
parent 3ea68f8f6c
commit 9a6f54de6c

View File

@ -140,9 +140,9 @@ Spork.prefork do
Time.stubs(:now).returns(time) Time.stubs(:now).returns(time)
end end
def file_from_fixtures(filename) def file_from_fixtures(filename, directory="images")
FileUtils.mkdir_p("#{Rails.root}/tmp/spec") unless Dir.exists?("#{Rails.root}/tmp/spec") FileUtils.mkdir_p("#{Rails.root}/tmp/spec") unless Dir.exists?("#{Rails.root}/tmp/spec")
FileUtils.cp("#{Rails.root}/spec/fixtures/images/#{filename}", "#{Rails.root}/tmp/spec/#{filename}") FileUtils.cp("#{Rails.root}/spec/fixtures/#{directory}/#{filename}", "#{Rails.root}/tmp/spec/#{filename}")
File.new("#{Rails.root}/tmp/spec/#{filename}") File.new("#{Rails.root}/tmp/spec/#{filename}")
end end
end end