Class: Typhoeus::HydraMock

Inherits:
Object
  • Object
show all
Defined in:
lib/typhoeus/hydra.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url, method) ⇒ HydraMock

Returns a new instance of HydraMock.



221
222
223
224
225
# File 'lib/typhoeus/hydra.rb', line 221

def initialize(url, method)
  @url      = url
  @method   = method
  @requests = []
end

Instance Attribute Details

#methodObject (readonly)

Returns the value of attribute method.



219
220
221
# File 'lib/typhoeus/hydra.rb', line 219

def method
  @method
end

#requestsObject (readonly)

Returns the value of attribute requests.



219
220
221
# File 'lib/typhoeus/hydra.rb', line 219

def requests
  @requests
end

#responseObject (readonly)

Returns the value of attribute response.



219
220
221
# File 'lib/typhoeus/hydra.rb', line 219

def response
  @response
end

#urlObject (readonly)

Returns the value of attribute url.



219
220
221
# File 'lib/typhoeus/hydra.rb', line 219

def url
  @url
end

Instance Method Details

#add_request(request) ⇒ Object



227
228
229
# File 'lib/typhoeus/hydra.rb', line 227

def add_request(request)
  @requests << request
end

#and_return(val) ⇒ Object



231
232
233
# File 'lib/typhoeus/hydra.rb', line 231

def and_return(val)
  @response = val
end

#matches?(request) ⇒ Boolean

Returns:

  • (Boolean)


235
236
237
238
239
240
241
# File 'lib/typhoeus/hydra.rb', line 235

def matches?(request)
  if url.kind_of?(String)
    request.method == method && request.url == url
  else
    request.method == method && url =~ request.url
  end
end