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.



185
186
187
188
189
# File 'lib/typhoeus/hydra.rb', line 185

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

Instance Attribute Details

#methodObject (readonly)

Returns the value of attribute method.



183
184
185
# File 'lib/typhoeus/hydra.rb', line 183

def method
  @method
end

#requestsObject (readonly)

Returns the value of attribute requests.



183
184
185
# File 'lib/typhoeus/hydra.rb', line 183

def requests
  @requests
end

#responseObject (readonly)

Returns the value of attribute response.



183
184
185
# File 'lib/typhoeus/hydra.rb', line 183

def response
  @response
end

#urlObject (readonly)

Returns the value of attribute url.



183
184
185
# File 'lib/typhoeus/hydra.rb', line 183

def url
  @url
end

Instance Method Details

#add_request(request) ⇒ Object



191
192
193
# File 'lib/typhoeus/hydra.rb', line 191

def add_request(request)
  @requests << request
end

#and_return(val) ⇒ Object



195
196
197
# File 'lib/typhoeus/hydra.rb', line 195

def and_return(val)
  @response = val
end

#matches?(request) ⇒ Boolean

Returns:

  • (Boolean)


199
200
201
202
203
204
205
# File 'lib/typhoeus/hydra.rb', line 199

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