Sha256: 4316dd69be9359f2facee5a7452b80eb05b8c2ce87cdcdf23cfea392270ce6ef

Contents?: true

Size: 793 Bytes

Versions: 83

Compression:

Stored size: 793 Bytes

Contents

require 'rails_helper'

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

  describe 'basic create' do
    let(:params) do
      <%- if defined?(FactoryBot) -%>
      attributes_for(:<%= type.to_s.singularize %>)
      <%- else -%>
      {
        # ... your attrs here
      }
      <%- end -%>
    end
    let(:payload) do
      {
        data: {
          type: '<%= type %>',
          attributes: params
        }
      }
    end

    it 'works' do
      expect(<%= resource_class %>).to receive(:build).and_call_original
      expect {
        make_request
        expect(response.status).to eq(201), response.body
      }.to change { <%= model_class %>.count }.by(1)
    end
  end
end

Version data entries

83 entries across 83 versions & 2 rubygems

Version Path
graphiti-1.8.1 deprecated_generators/graphiti/templates/create_request_spec.rb.erb
graphiti-1.8.0 deprecated_generators/graphiti/templates/create_request_spec.rb.erb
graphiti-1.7.9 deprecated_generators/graphiti/templates/create_request_spec.rb.erb
graphiti-1.7.8 deprecated_generators/graphiti/templates/create_request_spec.rb.erb
graphiti-1.7.7 deprecated_generators/graphiti/templates/create_request_spec.rb.erb
graphiti-1.7.6 deprecated_generators/graphiti/templates/create_request_spec.rb.erb
graphiti-1.7.5 deprecated_generators/graphiti/templates/create_request_spec.rb.erb
graphiti-1.7.4 deprecated_generators/graphiti/templates/create_request_spec.rb.erb
graphiti-1.7.3 deprecated_generators/graphiti/templates/create_request_spec.rb.erb
graphiti-1.7.2 deprecated_generators/graphiti/templates/create_request_spec.rb.erb
graphiti-1.7.1 deprecated_generators/graphiti/templates/create_request_spec.rb.erb
graphiti-1.7.0 deprecated_generators/graphiti/templates/create_request_spec.rb.erb
graphiti-1.6.4 deprecated_generators/graphiti/templates/create_request_spec.rb.erb
graphiti-1.6.3 deprecated_generators/graphiti/templates/create_request_spec.rb.erb
graphiti-1.6.2 deprecated_generators/graphiti/templates/create_request_spec.rb.erb
graphiti-1.6.1 deprecated_generators/graphiti/templates/create_request_spec.rb.erb
graphiti-1.6.0 deprecated_generators/graphiti/templates/create_request_spec.rb.erb
graphiti-1.5.3 deprecated_generators/graphiti/templates/create_request_spec.rb.erb
graphiti-1.5.2 deprecated_generators/graphiti/templates/create_request_spec.rb.erb
graphiti-1.5.1 deprecated_generators/graphiti/templates/create_request_spec.rb.erb