Sha256: 7354691feba1f678e5a8d4d13edbee742e3e8b71312cf75d44f8c06db8ede861

Contents?: true

Size: 659 Bytes

Versions: 4

Compression:

Stored size: 659 Bytes

Contents

require 'rails_helper'

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

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

    it 'updates the resource' do
      expect(<%= resource_klass %>).to receive(:find).and_call_original
      expect { make_request }.to change { <%= model_klass %>.count }.by(-1)
      expect { <%= file_name %>.reload }
        .to raise_error(ActiveRecord::RecordNotFound)
      expect(response.status).to eq(200)
      expect(json).to eq('meta' => {})
    end
  end
end

Version data entries

4 entries across 4 versions & 2 rubygems

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