Sha256: a9f01f02dc8ad72ec30ef7de3bc6d091a2e64c2b60c895d1f162a5e2c4d10be9

Contents?: true

Size: 760 Bytes

Versions: 6

Compression:

Stored size: 760 Bytes

Contents

require 'rails_helper'

RSpec.describe "<%= type %>#update", type: :request do
  context 'basic update' do
    let!(:<%= file_name %>) { create(:<%= file_name %>) }

    let(:payload) do
      {
        data: {
          id: <%= file_name %>.id.to_s,
          type: '<%= type %>',
          attributes: {
            # ... your attrs here
          }
        }
      }
    end

    # Replace 'xit' with 'it' after adding attributes
    xit 'updates the resource' do
      expect {
        jsonapi_put "/<%= api_namespace %>/v1/<%= type %>/#{<%= file_name %>.id}", payload
      }.to change { <%= file_name %>.reload.attributes }
      assert_payload(:<%= file_name %>, <%= file_name %>, json_item)

      # ... assert updates attributes ...
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
jsonapi_compliable-0.11.0 lib/generators/jsonapi/templates/update_request_spec.rb.erb
jsonapi_compliable-0.10.9 lib/generators/jsonapi/templates/update_request_spec.rb.erb
jsonapi_compliable-0.10.7 lib/generators/jsonapi/templates/update_request_spec.rb.erb
jsonapi_compliable-0.10.6 lib/generators/jsonapi/templates/update_request_spec.rb.erb
jsonapi_compliable-0.10.5 lib/generators/jsonapi/templates/update_request_spec.rb.erb
jsonapi_compliable-0.10.4 lib/generators/jsonapi/templates/update_request_spec.rb.erb