Sha256: 5f5abc2569ac03ab04b321a902e0a61d8245ac789e16c5be6c64095002724ac5

Contents?: true

Size: 1 KB

Versions: 2

Compression:

Stored size: 1 KB

Contents

require 'spec_helper'

<%
def value_for_check(attribute)
  case attribute.type
  when :references, :belongs_to
    "have_content(@#{ns_file_name}.#{attribute.name}.try(:name) || @#{ns_file_name}.#{attribute.name}.try(:id))"
  when :boolean
    "have_css(\"img.\#{@#{ns_file_name}.#{attribute.name} ? \"ico_true\" : \"ico_false\"}\")"
  else
    "have_content(@#{ns_file_name}.#{attribute.name})"
  end
end
%>

<% output_attributes = attributes.reject{|attribute| [:datetime, :timestamp, :time, :date].index(attribute.type) } -%>
describe "<%= ns_table_name %>/show.html.<%= options[:template_engine] %>" do
  before(:each) do
    @<%= ns_file_name %> = assign(:<%= ns_file_name %>, Factory(:<%= ns_file_name %>) )
    <%- base_parent_resources.each do |parent| -%>
    @<%= parent %> = assign(:<%= parent %>, @<%= ns_file_name %>.<%= parent %>)
    <%- end -%>
  end

  it "renders attributes" do
    render
<% for attribute in output_attributes -%>
    rendered.should <%= value_for_check(attribute) %>
<% end -%>
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
leonardo-1.6.1 lib/generators/leolay/templates/lib/templates/rspec/scaffold/show_spec.rb
leonardo-1.6.0 lib/generators/leolay/templates/lib/templates/rspec/scaffold/show_spec.rb