Sha256: 565b1158b14ef9d6e9049a919c096bce586768528c470381fe8f61bf19443749

Contents?: true

Size: 1.07 KB

Versions: 4

Compression:

Stored size: 1.07 KB

Contents

require 'rails_helper'

<% output_attributes = attributes.reject{|attribute| [:datetime, :timestamp, :time, :date].index(attribute.type) } -%>
RSpec.describe "<%= ns_table_name %>/edit", <%= type_metatag(:view) %> do
  let(:<%= ns_file_name %>) {
    <%= class_name %>.create!(<%= ')' 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 -%>
<%= "    )\n" unless output_attributes.empty? -%>
  }

  before(:each) do
    assign(:<%= ns_file_name %>, <%= ns_file_name %>)
  end

  it "renders the edit <%= ns_file_name %> form" do
    render

    assert_select "form[action=?][method=?]", <%= ns_file_name %>_path(<%= ns_file_name %>), "post" do
<% for attribute in output_attributes -%>
      <%- name = attribute.respond_to?(:column_name) ? attribute.column_name : attribute.name %>
      assert_select "<%= attribute.input_type -%>[name=?]", "<%= ns_file_name %>[<%= name %>]"
<% end -%>
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rspec-rails-6.0.3 lib/generators/rspec/scaffold/templates/edit_spec.rb
rspec-rails-6.0.2 lib/generators/rspec/scaffold/templates/edit_spec.rb
rspec-rails-6.0.1 lib/generators/rspec/scaffold/templates/edit_spec.rb
rspec-rails-6.0.0 lib/generators/rspec/scaffold/templates/edit_spec.rb