Sha256: 5b76bc35ae95a30708d383ce7103522b20b585139cca77ea45581c9261d65055

Contents?: true

Size: 1.21 KB

Versions: 9

Compression:

Stored size: 1.21 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
  before(:each) do
    @<%= ns_file_name %> = assign(:<%= 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 -%>
<%= output_attributes.empty? ? "" : "    ))\n" -%>
  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 %>
<% 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

9 entries across 9 versions & 2 rubygems

Version Path
rails_mini_profiler-0.2.0 vendor/bundle/ruby/3.0.0/gems/rspec-rails-4.1.2/lib/generators/rspec/scaffold/templates/edit_spec.rb
rspec-rails-4.1.2 lib/generators/rspec/scaffold/templates/edit_spec.rb
rspec-rails-4.1.1 lib/generators/rspec/scaffold/templates/edit_spec.rb
rspec-rails-4.1.0 lib/generators/rspec/scaffold/templates/edit_spec.rb
rspec-rails-4.0.2 lib/generators/rspec/scaffold/templates/edit_spec.rb
rspec-rails-4.0.1 lib/generators/rspec/scaffold/templates/edit_spec.rb
rspec-rails-4.0.0 lib/generators/rspec/scaffold/templates/edit_spec.rb
rspec-rails-4.0.0.rc1 lib/generators/rspec/scaffold/templates/edit_spec.rb
rspec-rails-4.0.0.beta4 lib/generators/rspec/scaffold/templates/edit_spec.rb