Last active
December 11, 2015 17:59
-
-
Save jgv/4638576 to your computer and use it in GitHub Desktop.
Factory Girl definitions.
This file contains 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
# Picture factory definition | |
FactoryGirl.define do | |
factory :picture do | |
image { File.open(Dir.glob(File.join(Rails.root) + "/spec/support/pictures/*").sample) } | |
end | |
end |
This file contains 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
# Product factory definition | |
FactoryGirl.define do | |
factory :product do | |
name "a thing" | |
price "420" | |
description "blah blah blah" | |
slug "a-thing" | |
before(:create) {|p| | |
pics = [] | |
2.times { pics << FactoryGirl.create(:picture, :attachable => p) } | |
p.pics << pics | |
} | |
user | |
end | |
end |
This file contains 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
# User factory definition | |
FactoryGirl.define do | |
factory :user do | |
sequence(:email) {|n| "person-#{n}@okfoc.us" } | |
firstname "tester" | |
sequence(:lastname) {|n| "cool #{n}" } | |
password "password" | |
sequence(:username) {|n| "foo-#{n}" } | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment