summaryrefslogtreecommitdiff
path: root/spec/support/shared_examples
diff options
context:
space:
mode:
authorHombreLaser <sebastian-440@live.com>2023-02-24 21:29:13 -0600
committerHombreLaser <sebastian-440@live.com>2023-02-24 21:29:13 -0600
commitf758b80b4818fd98753167366191b203cdab306a (patch)
tree112dc9b620aeefc654763f8d42d42c34f1cc1fac /spec/support/shared_examples
parent53c55cbf14899d83023cf2e9b11ed204e7b630d3 (diff)
Refactoriza el suite de tests
Diffstat (limited to 'spec/support/shared_examples')
-rw-r--r--spec/support/shared_examples/requests/post_request.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/spec/support/shared_examples/requests/post_request.rb b/spec/support/shared_examples/requests/post_request.rb
new file mode 100644
index 0000000..6ea2a86
--- /dev/null
+++ b/spec/support/shared_examples/requests/post_request.rb
@@ -0,0 +1,19 @@
+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 to the posted data' do
+ post(route, params: params.to_json, 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 a error message' do
+ post('/api/authenticate', params: wrong_params.to_json, headers:)
+ expect(response).to have_http_status(desired_error_status)
+ expect(response.body).to include(expected_error_message)
+ end
+ end
+end