Sha256: 0fd392034427dbcd55c7fa7d1db89fdb89050602b0c697cf69f64c597de20809

Contents?: true

Size: 1013 Bytes

Versions: 15

Compression:

Stored size: 1013 Bytes

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(:<%= singular_table_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 %>
      assert_select "<%= attribute.input_type -%>[name=?]", "<%= ns_file_name %>[<%= name %>]"
<% end -%>
    end
  end
end

Version data entries

15 entries across 14 versions & 4 rubygems

Version Path
trusty-cms-7.0.9.1 vendor/bundle/ruby/3.1.0/gems/rspec-rails-7.1.0/lib/generators/rspec/scaffold/templates/new_spec.rb
trusty-cms-7.0.9.1 vendor/bundle/ruby/3.3.0/gems/rspec-rails-7.1.0/lib/generators/rspec/scaffold/templates/new_spec.rb
rspec-rails-7.1.0 lib/generators/rspec/scaffold/templates/new_spec.rb
rspec-rails-7.0.2 lib/generators/rspec/scaffold/templates/new_spec.rb
rspec-rails-7.0.1 lib/generators/rspec/scaffold/templates/new_spec.rb
rspec-rails-7.0.0 lib/generators/rspec/scaffold/templates/new_spec.rb
rspec-rails-6.1.5 lib/generators/rspec/scaffold/templates/new_spec.rb
rspec-rails-6.1.4 lib/generators/rspec/scaffold/templates/new_spec.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/rspec-rails-6.1.3/lib/generators/rspec/scaffold/templates/new_spec.rb
rspec-rails-6.1.3 lib/generators/rspec/scaffold/templates/new_spec.rb
tinymce-rails-7.1.2 vendor/bundle/ruby/3.3.0/gems/rspec-rails-6.0.4/lib/generators/rspec/scaffold/templates/new_spec.rb
rspec-rails-6.1.2 lib/generators/rspec/scaffold/templates/new_spec.rb
rspec-rails-6.1.1 lib/generators/rspec/scaffold/templates/new_spec.rb
rspec-rails-6.1.0 lib/generators/rspec/scaffold/templates/new_spec.rb
rspec-rails-6.0.4 lib/generators/rspec/scaffold/templates/new_spec.rb