summaryrefslogtreecommitdiff
path: root/spec/support/shared_examples/requests/get_request.rb
blob: d58da6725632abd7128541b85f7990e5edc39cdd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# frozen_string_literal: true

RSpec.shared_examples 'a GET resource request' do |sole_route: false|
  context 'for an existing resource' do
    it 'returns a 200 status and the requested resource(s)' do
      get(route, headers:)
      expect(response).to have_http_status(200)
      expect(response.body).to include_strings(expected_text)
    end
  end

  unless sole_route
    context 'for a nonexistent resource' do
      it 'returns a 404 http status' do
        get(invalid_route, headers:)
        expect(response).to have_http_status(404)
      end
    end
  end
end