Sha256: 6092db918795d66b90f1592b8327c5d22ba98e54df9906a03142dea5902ab727

Contents?: true

Size: 1.17 KB

Versions: 13

Compression:

Stored size: 1.17 KB

Contents

require 'rails_helper'

<% output_attributes = attributes.reject{|attribute| [:datetime, :timestamp, :time, :date].index(attribute.type) } -%>
RSpec.describe "<%= ns_table_name %>/new", <%= type_metatag(:view) %> do
  before(:each) do
    assign(:<%= ns_file_name %>, <%= class_name %>.new(<%= '))' if output_attributes.empty? %>
<% output_attributes.each_with_index do |attribute, attribute_index| -%>
      :<%= attribute.name %> => <%= attribute.default.inspect %><%= attribute_index == output_attributes.length - 1 ? '' : ','%>
<% end -%>
<%= !output_attributes.empty? ? "    ))\n  end" : "  end" %>

  it "renders new <%= ns_file_name %> form" do
    render

    assert_select "form[action=?][method=?]", <%= index_helper %>_path, "post" do
<% for attribute in output_attributes -%>
      <%- name = attribute.respond_to?(:column_name) ? attribute.column_name : attribute.name %>
<% if Rails.version.to_f >= 5.1 -%>
      assert_select "<%= attribute.input_type -%>[name=?]", "<%= ns_file_name %>[<%= name %>]"
<% else -%>
      assert_select "<%= attribute.input_type -%>#<%= ns_file_name %>_<%= name %>[name=?]", "<%= ns_file_name %>[<%= name %>]"
<% end -%>
<% end -%>
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
rspec-rails-3.9.1 lib/generators/rspec/scaffold/templates/new_spec.rb
rspec-rails-4.0.0.beta3 lib/generators/rspec/scaffold/templates/new_spec.rb
rspec-rails-3.8.3 lib/generators/rspec/scaffold/templates/new_spec.rb
rspec-rails-3.9.0 lib/generators/rspec/scaffold/templates/new_spec.rb
rspec-rails-4.0.0.beta2 lib/generators/rspec/scaffold/templates/new_spec.rb
rspec-rails-3.8.2 lib/generators/rspec/scaffold/templates/new_spec.rb
rspec-rails-3.8.1 lib/generators/rspec/scaffold/templates/new_spec.rb
rspec-rails-3.8.0 lib/generators/rspec/scaffold/templates/new_spec.rb
rspec-rails-3.7.2 lib/generators/rspec/scaffold/templates/new_spec.rb
rspec-rails-3.7.1 lib/generators/rspec/scaffold/templates/new_spec.rb
rspec-rails-3.7.0 lib/generators/rspec/scaffold/templates/new_spec.rb
rspec-rails-3.6.1 lib/generators/rspec/scaffold/templates/new_spec.rb
rspec-rails-3.6.0 lib/generators/rspec/scaffold/templates/new_spec.rb