Sha256: 90f139423063975aca35761dc5eb3e9f3293df1da7687a4299b36ea51cd0201f

Contents?: true

Size: 673 Bytes

Versions: 1

Compression:

Stored size: 673 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 %[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.0 lib/templates/factory_girl/model/fixtures.erb