Skip to content

Commit

Permalink
Add customer destroy_spec.rb test file
Browse files Browse the repository at this point in the history
  • Loading branch information
fabianoflorentino committed Mar 3, 2024
1 parent 8c1b03a commit 5e68c69
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions spec/requests/customer/destroy_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# frozen_string_literal: true

require 'rails_helper'

RSpec.describe 'DELETE - /customer' do
let(:customer) { create(:customer) }
let(:url) { '/customers' }

describe 'DELETE /customers/:id' do
context 'when the customer exists' do
it 'deletes the customer' do
delete("#{url}/#{customer.id}")

expect(response).to have_http_status(:ok)
expect(response.parsed_body).to include('message' => 'Customer deleted!')
end
end

context 'when the customer does not exist' do
it 'returns 404' do
delete("#{url}/0")

expect(response).to have_http_status(:not_found)
end
end
end
end

0 comments on commit 5e68c69

Please sign in to comment.