Skip to content

Instantly share code, notes, and snippets.

@alexkojin
Created November 21, 2016 09:21
Show Gist options
  • Save alexkojin/6a2d70f84ff91c37315d1d3edb0d8e6b to your computer and use it in GitHub Desktop.
Save alexkojin/6a2d70f84ff91c37315d1d3edb0d8e6b to your computer and use it in GitHub Desktop.
FactoryGirl shared resources
# shared_factories/sequences
FactoryGirl.define do
sequence :email do |n|
"email#{n}@example.com"
end
sequence(:name) { |n| "store#{n}" }
end
# factories/admins.rb
require_relative '../shared_factories/sequences'
FactoryGirl.define do
factory :admin do
email
password "12345678"
password_confirmation "12345678"
end
end
# factories/stores.rb
require_relative '../shared_factories/sequences'
FactoryGirl.define do
factory :store do
admin
name
theme 'game'
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment