-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add customer destroy_spec.rb test file
- Loading branch information
1 parent
8c1b03a
commit 5e68c69
Showing
1 changed file
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |