Skip to content
This repository has been archived by the owner on Mar 15, 2021. It is now read-only.

Commit

Permalink
Update fabricator.erb
Browse files Browse the repository at this point in the history
  • Loading branch information
joel committed Nov 25, 2019
1 parent 6a7d7e8 commit 221a176
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/rails/generators/fabrication/model/templates/fabricator.erb
@@ -1,8 +1,10 @@
<% module_namespacing do -%>
Fabricator(<%= class_name.match(/::/) ? "'#{class_name}'" : ":#{singular_name}" %><%= namespaced? ? ", from: #{class_name}" : ""%>) do
<% if namespaced? -%>
Fabricator(<%= ":#{singular_name}, from: '#{namespace}::#{class_name}'" %>) do
<% else -%>
Fabricator(<%= class_name.match(/::/) ? "'#{class_name}'" : ":#{singular_name}" %>) do
<% end -%>
<% width = attributes.map{|a| a.name.size }.max.to_i -%>
<% attributes.each do |attribute| -%>
<%= "%-#{width}s %s" % [attribute.name, attribute.default.inspect] %>
<% end -%>
end
<% end -%>
end

0 comments on commit 221a176

Please sign in to comment.