Sha256: 5f1f511c8973551e8cf9a09ea6a54442fd60403d614cfb5648905d61bc46733f

Contents?: true

Size: 640 Bytes

Versions: 33

Compression:

Stored size: 640 Bytes

Contents

require 'rails_helper'

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

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

    it 'creates the resource' do
      expect {
        make_request
      }.to change { <%= model_klass %>.count }.by(1)
      <%= file_name %> = <%= model_klass %>.last

      assert_payload(:<%= file_name %>, <%= file_name %>, json_item)
    end
  end
end

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
jsonapi_compliable-0.11.34 lib/generators/jsonapi/templates/create_request_spec.rb.erb
jsonapi_compliable-0.11.33 lib/generators/jsonapi/templates/create_request_spec.rb.erb
jsonapi_compliable-0.11.32 lib/generators/jsonapi/templates/create_request_spec.rb.erb
jsonapi_compliable-0.11.31 lib/generators/jsonapi/templates/create_request_spec.rb.erb
jsonapi_compliable-0.11.30 lib/generators/jsonapi/templates/create_request_spec.rb.erb
jsonapi_compliable-0.11.29 lib/generators/jsonapi/templates/create_request_spec.rb.erb
jsonapi_compliable-0.11.28 lib/generators/jsonapi/templates/create_request_spec.rb.erb
jsonapi_compliable-0.11.27 lib/generators/jsonapi/templates/create_request_spec.rb.erb
jsonapi_compliable-0.11.26 lib/generators/jsonapi/templates/create_request_spec.rb.erb
jsonapi_compliable-0.11.25 lib/generators/jsonapi/templates/create_request_spec.rb.erb
jsonapi_compliable-0.11.24 lib/generators/jsonapi/templates/create_request_spec.rb.erb
jsonapi_compliable-0.11.23 lib/generators/jsonapi/templates/create_request_spec.rb.erb
jsonapi_compliable-0.11.22 lib/generators/jsonapi/templates/create_request_spec.rb.erb
jsonapi_compliable-0.11.21 lib/generators/jsonapi/templates/create_request_spec.rb.erb
jsonapi_compliable-0.11.20 lib/generators/jsonapi/templates/create_request_spec.rb.erb
jsonapi_compliable-0.11.19 lib/generators/jsonapi/templates/create_request_spec.rb.erb
jsonapi_compliable-0.11.18 lib/generators/jsonapi/templates/create_request_spec.rb.erb
jsonapi_compliable-0.11.17 lib/generators/jsonapi/templates/create_request_spec.rb.erb
jsonapi_compliable-0.11.16 lib/generators/jsonapi/templates/create_request_spec.rb.erb
jsonapi_compliable-0.11.15 lib/generators/jsonapi/templates/create_request_spec.rb.erb