Module: RSpecApi::Expectations::Response::Headers

Included in:
RSpecApi::Expectations::Response
Defined in:
lib/rspec-api/expectations/headers.rb,
lib/rspec-api/expectations/headers/page_links.rb,
lib/rspec-api/expectations/headers/content_type.rb

Overview

Creates an example group for expectations on the response headers of last API request and runs it to verify that it matches best practices:

  • if request has entity body, the Content-Type header should be JSON

  • if request has pages, the Link header should have a ‘rel=prev’ link

Defined Under Namespace

Modules: ContentType, PageLinks

Instance Method Summary collapse

Instance Method Details

#expect_headers(response, expectations = {}) ⇒ Object



12
13
14
15
16
17
18
19
20
# File 'lib/rspec-api/expectations/headers.rb', line 12

def expect_headers(response, expectations = {})
  context 'responds with headers that' do
    extend ContentType
    extend PageLinks

    expect_content_type response, expectations
    expect_page_links response, expectations
  end if expectations.any?
end