Created
October 11, 2016 19:40
-
-
Save romikoops/e0ab0d49b86fc0e8c674f1ae0f2b99d0 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 'rubygems' | |
require 'bundler' | |
Bundler.require(:default) | |
include FactoryGirl::Syntax::Methods | |
# Models | |
class User | |
attr_accessor :first_name, :last_name, :email, :sex | |
attr_accessor :profile | |
def save! | |
puts first_name | |
end | |
end | |
class Profile | |
attr_accessor :age | |
def save! | |
puts "Profile saved" | |
end | |
end | |
# DEFINITIONS | |
FactoryGirl.define do | |
factory :admin, class: :User do | |
first_name { 'Petr' } | |
last_name { 'Ivanov'} | |
profile | |
end | |
factory :profile do | |
age 30 | |
end | |
end | |
FactoryGirl.find_definitions | |
# USAGE | |
p build(:admin).profile.age |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment