Module: KnowsAboutApiResponses

Defined in:
lib/cucumber/blinkbox/responses.rb

Instance Method Summary collapse

Instance Method Details

#parse_response_dataHash

Parses response data that is expected to be in JSON format.

Returns:

  • (Hash)

    The response data.


7
8
9
10
11
12
13
14
# File 'lib/cucumber/blinkbox/responses.rb', line 7

def parse_response_data
  expect(HttpCapture::RESPONSES.last["Content-Type"]).to match(%r{^application/vnd.blinkboxbooks.data.v1\+json;?})
  begin
    @response_data = JSON.load(HttpCapture::RESPONSES.last.body)
  rescue => e
    raise "The response is not valid JSON: #{e.message}"
  end
end