Sha256: f44f7d7b98975a6ce8f2037d577c6d0410f4dde250f928e44c8b2c8cdefb0045

Contents?: true

Size: 823 Bytes

Versions: 1

Compression:

Stored size: 823 Bytes

Contents

require 'rails_helper'

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

  describe 'basic update' do
    let!(:<%= var %>) { create(:<%= var %>) }

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

    # Replace 'xit' with 'it' after adding attributes
    xit 'updates the resource' do
      expect(<%= resource_class %>).to receive(:find).and_call_original
      expect {
        make_request
      }.to change { <%= var %>.reload.attributes }
      expect(response.status).to eq(200)

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
graphiti-1.0.alpha.19 lib/generators/graphiti/templates/update_request_spec.rb.erb