Created
June 8, 2012 23:51
-
-
Save jeffrydegrande/2898729 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
# So .. if I really need to have different behavior | |
# based on gender ... | |
class Male < Person | |
end | |
class Female < Person | |
end | |
FactoryGirl.define do | |
factory :john, :class => Male do | |
name "john" | |
end | |
factory "joe", :class => Male do | |
end | |
# or even | |
factory :dude, :class => Male do | |
end | |
factory :john, :parent => :dude do | |
end | |
end | |
# I usually don't so I probably end up with | |
class Person | |
attr_accessor :gender | |
end | |
Person.new.gender = :male # I like to use symbols in code and convert them to string | |
Person.new.gender = :female | |
FactoryGirl.define do | |
factory :john, :class => Person do | |
name 'John Doe' | |
gender :male | |
end | |
factory :joe, :class => Person do | |
name 'John Roe' | |
gender :male | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment