Skip to content

Instantly share code, notes, and snippets.

@abepetrillo
Created May 20, 2016 19:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abepetrillo/d32a925c27b7f476eb89a27f89f0788f to your computer and use it in GitHub Desktop.
Save abepetrillo/d32a925c27b7f476eb89a27f89f0788f to your computer and use it in GitHub Desktop.
require 'rails_helper'
describe DocumentsController do
describe '#create' do
it 'persists a file' do
file_path = File.join(Rails.root, 'tmp', SecureRandom.uuid)
File.open(file_path, 'w+b') { |f| f.write "A random file used for testing attachments!" }
file = Rack::Test::UploadedFile.new(file_path, 'text/plain')
post :create, {file: file}
expect(Document.last.file).to eql 'A random file used for testing attachments!'
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment