require 'rails_helper'

RSpec.describe "<%= type %>#create", type: :request do
  subject(:make_request) do
    jsonapi_post "<%= api_namespace %>/<%= type %>", payload
  end

  describe 'basic create' do
    let(:payload) do
      {
        data: {
          type: '<%= type %>',
          attributes: {
            # ... your attrs here
          }
        }
      }
    end

    it 'works' do
      expect(<%= resource_class %>).to receive(:build).and_call_original
      expect {
        make_request
      }.to change { <%= model_class %>.count }.by(1)
      expect(response.status).to eq(201)
    end
  end
end

require 'rails_helper'

RSpec.describe "<%= type %>#create", type: :request do
  subject(:make_request) do
    jsonapi_post "<%= api_namespace %>/<%= type %>", payload
  end

  describe 'basic create' do
    let(:params) do
      <%- if defined?(FactoryBot) %>
      FactoryBot.build(:<%= type.to_s.singularize %>).attributes.
      except("created_at", "updated_at")
      <%- else %>
      {
        # ... your attrs here
      }
      <%- end %>
    end
    let(:payload) do
      {
        data: {
          type: '<%= type %>',
          attributes: params
        }
      }
    end

    it 'works' do
      expect(<%= resource_class %>).to receive(:build).and_call_original
      expect {
        make_request
      }.to change { <%= model_class %>.count }.by(1)
      expect(response.status).to eq(201)
    end
  end
end

Use FactoryBot to generate params in the create_spec
Use FactoryBot to generate params in the create_spec

If FactoryBot exists, use it to generate the params for the basic spec
