summaryrefslogtreecommitdiff
path: root/spec/support/shared_examples/requests
diff options
context:
space:
mode:
authorHombreLaser <sebastian-440@live.com>2023-03-11 11:42:32 -0600
committerHombreLaser <sebastian-440@live.com>2023-03-11 11:42:32 -0600
commit6b3cc5c3a33643c0e42396142a2d3204ada2bb82 (patch)
treecd5040d31e523a7c4a1818fd6aad9f6b3ef325d5 /spec/support/shared_examples/requests
parent62f0c7caa84ee7383e798e93419408b39f64467b (diff)
Añade spec de update company
Diffstat (limited to 'spec/support/shared_examples/requests')
-rw-r--r--spec/support/shared_examples/requests/post_request.rb4
-rw-r--r--spec/support/shared_examples/requests/put_request.rb26
2 files changed, 27 insertions, 3 deletions
diff --git a/spec/support/shared_examples/requests/post_request.rb b/spec/support/shared_examples/requests/post_request.rb
index c7b8d77..55d35a4 100644
--- a/spec/support/shared_examples/requests/post_request.rb
+++ b/spec/support/shared_examples/requests/post_request.rb
@@ -1,11 +1,9 @@
# frozen_string_literal: true
RSpec.shared_examples 'a POST request' do
- let(:headers) { { 'CONTENT_TYPE' => 'application/json' } }
-
context 'with correct parameters' do
it 'returns a successful http status and a response with the posted data' do
- post(route, params: params, headers:)
+ post(route, params:, headers:)
expect(response).to have_http_status(200)
expect(response.body).to include_strings(expected_text)
end
diff --git a/spec/support/shared_examples/requests/put_request.rb b/spec/support/shared_examples/requests/put_request.rb
new file mode 100644
index 0000000..9e46235
--- /dev/null
+++ b/spec/support/shared_examples/requests/put_request.rb
@@ -0,0 +1,26 @@
+# frozen_string_literal: true
+
+RSpec.shared_examples 'a PUT request' do
+ context 'with correct parameters' do
+ it 'returns a successful http status and a response with the putted data' do
+ put(route, params:, headers:)
+ expect(response).to have_http_status(200)
+ expect(response.body).to include_strings(expected_text)
+ end
+ end
+
+ context 'with incorrect parameters' do
+ it 'returns a client side error http status and an error message' do
+ put(route, params: wrong_params, headers:)
+ expect(response).to have_http_status(desired_error_status)
+ expect(response.body).to include_strings(expected_error_messages)
+ end
+ end
+
+ context 'to an nonexistent resource' do
+ it 'returns a 404 status' do
+ put(wrong_route, params:, headers:)
+ expect(response).to have_http_status(404)
+ end
+ end
+end