Skip to content

Instantly share code, notes, and snippets.

@bnmrrs
Created March 16, 2016 00:13
Show Gist options
  • Save bnmrrs/cd1a78e3f9cb8a9cea3c to your computer and use it in GitHub Desktop.
Save bnmrrs/cd1a78e3f9cb8a9cea3c to your computer and use it in GitHub Desktop.
FactoryGirl.define do
factory :cocktail do
name "Desert Healer"
user
photo Rack::Test::UploadedFile.new(File.open(Rails.root.join("spec/fixtures/files/deserthealer.jpg")))
ingredients { build_list(:ingredient, 1) }
end
end
FactoryGirl.define do
factory :ingredient do
name "Bourbon"
quantity 1
unit "oz"
after(:build) do |i|
i.cocktail = build(:cocktail, ingredients: [i]) unless i.cocktail
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment