Sha256: 2e61bd64074424763271b421c132b26978aaf72ea495501c6c4ceb4555b0c180

Contents?: true

Size: 857 Bytes

Versions: 4

Compression:

Stored size: 857 Bytes

Contents

require 'rails_helper'

RSpec.describe "<%= type %>#update", type: :request do
  subject(:make_request) do
    jsonapi_put "/<%= api_namespace %>/v1/<%= type %>/#{<%= file_name %>.id}", payload
  end

  describe '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(<%= resource_klass %>).to receive(:find).and_call_original
      expect {
        make_request
      }.to change { <%= file_name %>.reload.attributes }
      expect(response.status).to eq(200)

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

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
graphiti-1.0.alpha.5 lib/generators/jsonapi/templates/update_request_spec.rb.erb
graphiti-1.0.alpha.4 lib/generators/jsonapi/templates/update_request_spec.rb.erb
graphiti-1.0.alpha.1 lib/generators/jsonapi/templates/update_request_spec.rb.erb
graphiti-rb-1.0.alpha.1 lib/generators/jsonapi/templates/update_request_spec.rb.erb