summaryrefslogtreecommitdiff
path: root/spec/support/shared_examples/requests/put_request.rb
blob: 9e46235920fdc9a1975fb584aedf237692e98866 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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