Sha256: 963f3cd6a48a78f4f69fd6ceaffa5afbcb6223c75bff3a3227959aa6b0a3681d
Contents?: true
Size: 1.2 KB
Versions: 2
Compression:
Stored size: 1.2 KB
Contents
require "http_capture" require "rack" module Cucumber module Rest # Helper functions for checking the cacheability of responses. module Status def self.ensure_status(expected, response: HttpCapture::RESPONSES.last) actual = response.status unless expected == actual actual_name = Rack::Utils::HTTP_STATUS_CODES[actual] expected_name = Rack::Utils::HTTP_STATUS_CODES[expected] message = "Request status was #{actual} #{actual_name}; expected #{expected} #{expected_name}" raise message end end def self.ensure_status_class(expected, response: HttpCapture::RESPONSES.last) min = case expected when :informational then 100 when :success then 200 when :redirection then 300 when :client_error then 400 when :server_error then 500 end max = min + 99 expected_range = min..max actual = response.status unless expected_range === actual message = "Request status was #{actual} #{Rack::Utils::HTTP_STATUS_CODES[actual]}; expected #{expected_range}" raise message end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
cucumber-rest-0.1.10 | lib/cucumber/rest/status.rb |
cucumber-rest-0.0.0 | lib/cucumber/rest/status.rb |