Sha256: f869284f99c6cff563c0484d7111cc792fda6bcc59bd3b93d726ce7b1b0ec140

Contents?: true

Size: 950 Bytes

Versions: 1

Compression:

Stored size: 950 Bytes

Contents

<%- unless ModelBase.config.frozen_string_literal.nil? -%>
# frozen_string_literal: <%= ModelBase.config.frozen_string_literal.inspect %>
<%- end -%>
<%- columns = model.columns_for(:factory) rescue nil-%>
<%- if columns -%>
FactoryGirl.define do
  factory :<%= model.full_resource_name %> do
<%- model.columns_for(:factory).each do |col| -%>
  <%- if col.reference -%>
    <%- if col.required? -%>
    association :<%= col.reference.name %>, factory: :<%= col.ref_model.full_resource_name %>
    <%- else -%>
    <%= col.reference.name %> nil
    <%- end -%>
  <%- else -%>
    <%= col.name %> <%= col.sample_value(context: :factory).inspect.gsub(/\A\"|\"\z/, "'") %>
  <%- end -%>
<%- end -%>
  end
end
<%- else -%>
FactoryGirl.define do
  factory :<%= singular_table_name %><%= explicit_class_option %> do
    <%- attributes.map do |attribute| -%>
      <%= attribute.name %> <%= attribute.default.inspect %>
    <%- end -%>
  end
end
<%- end -%>

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
model_base_generators-0.3.9 lib/templates/factory_girl/factory.rb