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
1 changed files with 2 additions and 2 deletions

View File

@ -140,9 +140,9 @@ Spork.prefork do
Time.stubs(:now).returns(time)
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.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}")
end
end