lib/manticore/stubbed_response.rb
def stub(stubs)
      if stubs.key? :cookies
        stubs[:cookies].keys.each { |key| stubs[:cookies][key] = Array(stubs[:cookies][key]) }
      end
      stubs[:code] ||= 200

      stubs[:headers] ||= {}
      stubs[:headers] = Hash[*stubs[:headers].flat_map { |k, v| [k.downcase, v] }]
      stubs[:headers]["content-length"] ||= stubs[:body].length.to_s if stubs.key?(:body)

      @stubs = stubs

      self
    end
# Stub out a Manticore::RequestStub.
#
# @param  stubs [Hash] Parameters to stub out
# @option stubs [String]                   body  The body that should be returned
# @option stubs [Integer]                  code  Response code to simulate
# @option stubs [Hash]                     headers  Response headers as a hash
# @option stubs [Array<Manticore::Cookie>] cookies
# @return [Manticore::StubbedResponse] self
Stub out a Manticore::RequestStub.
Stub out a Manticore :: RequestStub .
def stub(stubs)
      if stubs.key? :cookies
        stubs[:cookies].keys.each { |key| stubs[:cookies][key] = Array(stubs[:cookies][key]) }
      end
      stubs[:code] ||= 200
      stubs[:headers] ||= {}
      stubs[:headers] = Hash[*stubs[:headers].flat_map { |k, v| [k.downcase, v] }]
      stubs[:headers]["content-length"] ||= stubs[:body].length.to_s if stubs.key?(:body)
      @stubs = stubs
      self
    end
def stub ( stubs ) if stubs . key? :cookies stubs [ :cookies ] . keys . each { | key | stubs [ :cookies ] [ key ] = Array ( stubs [ :cookies ] [ key ] ) } end stubs [ :code ] ||= 200 stubs [ :headers ] ||= { } stubs [ :headers ] = Hash [ * stubs [ :headers ] . flat_map { | k , v | [ k . downcase , v ] } ] stubs [ :headers ] [ "content-length" ] ||= stubs [ :body ] . length . to_s if stubs . key? ( :body ) @stubs = stubs self end
Stub out a Manticore::RequestStub.
Stub out a Manticore :: RequestStub .
None
Manticore::StubbedResponse
stubs
None