Sha256: 6079935e35445a5b1898539e744ae347ba7fe7efc559114e8696712863c28825

Contents?: true

Size: 817 Bytes

Versions: 1

Compression:

Stored size: 817 Bytes

Contents

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 /\A.*_([a-z]{2}(_[a-z]{2})?)\z/.match attribute.name -%>
    sequence(:<%= attribute.name %>) {|n| "<%= class_name %>_<%= $1 %>#{n}" }
<% elsif %[name title].include? attribute.name -%>
    sequence(:<%= attribute.name %>) {|n| "<%= class_name %> ##{n}" }
<% elsif attribute.name == 'position' -%>
    sequence(:<%= attribute.name %>) {|n| n }
<% else -%>
    <%= attribute.name %> <%= attribute.default.inspect %>
<% end -%>
<% end -%>
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
factory_girl_fixtures_template-1.0.1 lib/templates/factory_girl/model/fixtures.erb