Sha256: f57b3e7087b5c57b94a84829cb3093210c0cd68cf652d2694a1360f1213cfd86

Contents?: true

Size: 692 Bytes

Versions: 12

Compression:

Stored size: 692 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 'works' do
      expect(<%= resource_class %>).to receive(:build).and_call_original
      expect {
        make_request
      }.to change { <%= model_class %>.count }.by(1)
      <%= var %> = <%= model_class %>.last
      # assert on properties
      expect(response.status).to eq(201)
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
graphiti-1.0.alpha.18 lib/generators/graphiti/templates/create_request_spec.rb.erb
graphiti-1.0.alpha.17 lib/generators/graphiti/templates/create_request_spec.rb.erb
graphiti-1.0.alpha.16 lib/generators/graphiti/templates/create_request_spec.rb.erb
graphiti-1.0.alpha.15 lib/generators/graphiti/templates/create_request_spec.rb.erb
graphiti-1.0.alpha.14 lib/generators/graphiti/templates/create_request_spec.rb.erb
graphiti-1.0.alpha.12 lib/generators/graphiti/templates/create_request_spec.rb.erb
graphiti-1.0.alpha.11 lib/generators/graphiti/templates/create_request_spec.rb.erb
graphiti-1.0.alpha.10 lib/generators/graphiti/templates/create_request_spec.rb.erb
graphiti-1.0.alpha.9 lib/generators/graphiti/templates/create_request_spec.rb.erb
graphiti-1.0.alpha.8 lib/generators/graphiti/templates/create_request_spec.rb.erb
graphiti-1.0.alpha.7 lib/generators/graphiti/templates/create_request_spec.rb.erb
graphiti-1.0.alpha.6 lib/generators/graphiti/templates/create_request_spec.rb.erb