Sha256: 95b6c26b80831b66f6aeb549a2a2db8d21c961d3fe1dded2caf0c4614a3f0173

Contents?: true

Size: 517 Bytes

Versions: 28

Compression:

Stored size: 517 Bytes

Contents

require "faraday"

module Faraday
  class UnexpectedResponse < RuntimeError
    attr_reader :response

    def initialize(response)
      @response = response
      super "Unexpected response (#{response.status}) from #{response.env[:url].host}#{response.env[:url].path}"
    end
  end

  module Expect
    def expect!(*status_codes)
      return if status_codes.include?(status)
      fail UnexpectedResponse.new(self)
    end
    alias :must_be! :expect!
  end
end

Faraday::Response.send :include, Faraday::Expect

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
houston-core-0.9.2 lib/unexpected_response.rb
houston-core-0.9.1 lib/unexpected_response.rb
houston-core-0.9.0 lib/unexpected_response.rb
houston-core-0.9.0.rc1 lib/unexpected_response.rb
houston-core-0.8.4 lib/unexpected_response.rb
houston-core-0.8.3 lib/unexpected_response.rb
houston-core-0.8.2 lib/unexpected_response.rb
houston-core-0.8.1 lib/unexpected_response.rb
houston-core-0.8.0 lib/unexpected_response.rb
houston-core-0.8.0.pre2 lib/unexpected_response.rb
houston-core-0.8.0.pre lib/unexpected_response.rb
houston-core-0.7.0 lib/unexpected_response.rb
houston-core-0.7.0.beta4 lib/unexpected_response.rb
houston-core-0.7.0.beta3 lib/unexpected_response.rb
houston-core-0.7.0.beta2 lib/unexpected_response.rb
houston-core-0.7.0.beta lib/unexpected_response.rb
houston-core-0.6.3 lib/unexpected_response.rb
houston-core-0.6.2 lib/unexpected_response.rb
houston-core-0.6.1 lib/unexpected_response.rb
houston-core-0.6.0 lib/unexpected_response.rb