require 'spec_helper' <% def value_for_check(attribute) name = ":text" ([] << case attribute.type when :boolean "\"tr#tr\#{r.id}>td>img.\#{r.#{attribute.name} ? \"ico_true\" : \"ico_false\"}\"" else "\"tr#tr\#{r.id}>td\"" end << case attribute.type when :references, :belongs_to "#{name} => (r.#{attribute.name}.try(:name) || r.#{attribute.name}.try(:id))" when :boolean nil else "#{name} => r.#{attribute.name}" end << ":count => 1" ).compact.join(', ') end %> <% output_attributes = attributes.reject{|attribute| [:datetime, :timestamp, :time, :date].index(attribute.type) } -%> describe "<%= ns_table_name %>/index.html.<%= options[:template_engine] %>" do before(:each) do @records = assign(:<%= table_name %>, FactoryGirl.create_list(:<%= ns_file_name %>, 2) ) assign(:<%= ns_file_name %>, Factory(:<%= ns_file_name %>) ) end it "renders a list of <%= ns_table_name %>" do render @records.each do |r| <% for attribute in output_attributes -%> assert_select <%= value_for_check(attribute) %> <% end -%> end end end