Skip to content

Commit

Permalink
more scaffold/spec tightening
Browse files Browse the repository at this point in the history
  • Loading branch information
rsl committed Jun 7, 2008
1 parent 43d34a1 commit 2059850
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
17 changes: 17 additions & 0 deletions generators/skinny_scaffold/templates/controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,24 @@
describe <%= controller_class_name %>Controller do
def valid_attributes(args = {})
{
<% if attributes.empty? -%>
# Add valid attributes for the your params[:<%= singular_name %>] here!
<% else -%>
<%- attributes.each_with_index do |attribute, index| -%>
<%- case attribute.type -%>
<%- when :string, :text -%>
:<%= attribute.name %> => "foo"<%= index < attributes.size - 1 ? "," : "" %>
<%- when :integer, :float, :decimal -%>
:<%= attribute.name %> => 815<%= index < attributes.size - 1 ? "," : "" %>
<%- when :boolean -%>
:<%= attribute.name %> => false<%= index < attributes.size - 1 ? "," : "" %>
<%- when :date, :datetime, :time, :timestamp -%>
:<%= attribute.name %> => 1.week.ago<%= index < attributes.size - 1 ? "," : "" %>
<%- else -%>
:<%= attribute.name %> => nil<%= index < attributes.size - 1 ? "," : "" %> # Could not determine valid attribute
<%- end -%>
<%- end -%>
<% end -%>
}.merge(args)
end

Expand Down
3 changes: 1 addition & 2 deletions generators/skinny_scaffold/templates/form.html.haml_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,13 @@
<%- when :date, :datetime, :time, :timestamp -%>
:<%= attribute.name %> => 1.week.ago<%= index < attributes.size - 1 ? "," : "" %>
<%- else -%>
:<%= attribute.name %> => nil<%= index < attributes.size - 1 ? "," : "" %>
:<%= attribute.name %> => nil<%= index < attributes.size - 1 ? "," : "" %> # Could not determine valid attribute
<%- end -%>
<%- end -%>
})
<% end -%>
end


it_should_have_form_for :<%= singular_name %>
<% if attributes.blank? -%>
# Add specs for editing attributes here, please! Like this:
Expand Down

0 comments on commit 2059850

Please sign in to comment.