Created
May 20, 2016 19:01
-
-
Save abepetrillo/d32a925c27b7f476eb89a27f89f0788f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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