Skip to content

Instantly share code, notes, and snippets.

@superbrothers
Forked from technicalpickles/factories.rb
Created September 16, 2011 10:27
Show Gist options
  • Save superbrothers/1221785 to your computer and use it in GitHub Desktop.
Save superbrothers/1221785 to your computer and use it in GitHub Desktop.
FactoryGirl.define do
factory :application do
attachment :sample, "public/samples/sample.doc", "application/msword"
end
end
require ActionDispatch::TestProcess
module FactoryGirl
DefinitionProxy.class_eval do
def attachment(name, path, content_type = nil)
path_with_rails_root = Rails.root.join(path)
uploaded_file = fixture_file_upload(path_with_rails_root, content_type)
add_attribute name, uploaded_file
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment