Sha256: d41702e6fffc57579c726c8a7b4848ab1751f28dcfdad16d343195b3e7e4025b

Contents?: true

Size: 629 Bytes

Versions: 15

Compression:

Stored size: 629 Bytes

Contents

# -*- encoding : utf-8 -*-
module UploadFileTestHelper
  def uploaded_file(filename, content_type = "text/csv")
    t = Tempfile.new([filename.split("/").last, filename.split(".").last])
    t.binmode
    path = File.join(Rails.root, "spec", "fixtures", filename)
    FileUtils.copy_file(path, t.path)
    ActionDispatch::Http::UploadedFile.new({
      filename: filename,
      head: "Content-Disposition: form-data; name=\"file\"; filename=\"#{filename}\"\r\nContent-Type: #{content_type}\r\n",
      type: content_type,
      tempfile: t
    })
  end
end

RSpec.configure do |config|
  config.include UploadFileTestHelper
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
pah-0.0.15 lib/pah/files/spec/support/uploaded_file.rb
pah-0.0.14 lib/pah/files/spec/support/uploaded_file.rb
pah-0.0.13 lib/pah/files/spec/support/uploaded_file.rb
pah-0.0.12 lib/pah/files/spec/support/uploaded_file.rb
pah-0.0.11 lib/pah/files/spec/support/uploaded_file.rb
pah-0.0.10 lib/pah/files/spec/support/uploaded_file.rb
pah-0.0.9 lib/pah/files/spec/support/uploaded_file.rb
pah-0.0.8 lib/pah/files/spec/support/uploaded_file.rb
pah-0.0.7 lib/pah/files/spec/support/uploaded_file.rb
pah-0.0.6 lib/pah/files/spec/support/uploaded_file.rb
pah-0.0.5 lib/pah/files/spec/support/uploaded_file.rb
pah-0.0.4 lib/pah/files/spec/support/uploaded_file.rb
pah-0.0.3 lib/pah/files/spec/support/uploaded_file.rb
pah-0.0.2 lib/pah/files/spec/support/uploaded_file.rb
pah-0.0.1 lib/pah/files/spec/support/uploaded_file.rb