Sha256: c44fd08f800aaf242acd4867b0be207d63d2df066158c91ab21fa1f93b51cdb6
Contents?: true
Size: 988 Bytes
Versions: 2
Compression:
Stored size: 988 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 == '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
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
factory_girl_fixtures_template-1.0.3 | lib/templates/factory_girl/model/fixtures.erb |
factory_girl_fixtures_template-1.0.2 | lib/templates/factory_girl/model/fixtures.erb |