FactoryGirl.define do factory :<%= singular_table_name %><%= explicit_class_option %> do <% for attribute in attributes -%> <% if attribute.reference? -%> <%= attribute.name %> { create :<%= attribute.name %> } <% elsif /\A(.*)_name\z/.match attribute.name -%> sequence(:<%= attribute.name %>) {|n| "<%= class_name %>_<%= $1.try :capitalize %>#{n}" } <% elsif I18n.available_locales.include? /\A.*?_([a-z]{2}(_[A-Z]{2})?)\z/.match(attribute.name).try(:[], 1).try(:to_sym) -%> sequence(:<%= attribute.name %>) {|n| "<%= class_name %>_<%= $1 %>#{n}" } <% elsif %[name title].include? attribute.name -%> sequence(:<%= attribute.name %>) {|n| "<%= class_name %> ##{n}" } <% elsif attribute.name == 'email' -%> sequence(:<%= attribute.name %>) {|n| "email#{n}@gmail.com" } <% elsif attribute.name == 'position' -%> sequence(:<%= attribute.name %>) {|n| n } <% elsif attribute.name == 'password' -%> password 'password' <% else -%> <%= attribute.name %> <%= attribute.default.inspect %> <% end -%> <% end -%> end end