Sha256: b0f8d8750a7805896aa80934c7e96cd681f3a22aa14ea0f00645f5c85d6ab91b

Contents?: true

Size: 1.18 KB

Versions: 4

Compression:

Stored size: 1.18 KB

Contents

require "test_helper"

<% module_namespacing do -%>
describe <%= controller_class_name %>Controller do
  <%- if mountable_engine? -%>
  include Engine.routes.url_helpers

  <%- end -%>
  let(:<%= singular_table_name %>) { <%= fixture_name %>(:one) }

  it "should get index" do
    get <%= index_helper %>_url, as: :json
    must_respond_with :success
  end

  it "should create <%= singular_table_name %>" do
    <%= spec_expectation_monad %> do
      post <%= index_helper %>_url, params: { <%= "#{singular_table_name}: { #{attributes_string} }" %> }, as: :json
    end.must_differ "<%= class_name %>.count"

    must_respond_with :created
  end

  it "should show <%= singular_table_name %>" do
    get <%= show_helper %>, as: :json
    must_respond_with :success
  end

  it "should update <%= singular_table_name %>" do
    patch <%= show_helper %>, params: { <%= "#{singular_table_name}: { #{attributes_string} }" %> }, as: :json
    must_respond_with :success
  end

  it "should destroy <%= singular_table_name %>" do
    <%= spec_expectation_monad %> do
      delete <%= show_helper %>, as: :json
    end.must_differ "<%= class_name %>.count", -1

    must_respond_with :no_content
  end
end
<% end -%>

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
minitest-rails-8.0.0 lib/generators/minitest/scaffold/templates/api_functional_spec.rb.tt
minitest-rails-7.2.0 lib/generators/minitest/scaffold/templates/api_functional_spec.rb.tt
minitest-rails-7.1.1 lib/generators/minitest/scaffold/templates/api_functional_spec.rb.tt
minitest-rails-7.1.0 lib/generators/minitest/scaffold/templates/api_functional_spec.rb.tt