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.



188
189
190
191
192
# File 'lib/typhoeus/hydra.rb', line 188

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

Instance Attribute Details

#methodObject (readonly)

Returns the value of attribute method.



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

def method
  @method
end

#requestsObject (readonly)

Returns the value of attribute requests.



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

def requests
  @requests
end

#responseObject (readonly)

Returns the value of attribute response.



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

def response
  @response
end

#urlObject (readonly)

Returns the value of attribute url.



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

def url
  @url
end

Instance Method Details

#add_request(request) ⇒ Object



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

def add_request(request)
  @requests << request
end

#and_return(val) ⇒ Object



198
199
200
# File 'lib/typhoeus/hydra.rb', line 198

def and_return(val)
  @response = val
end

#matches?(request) ⇒ Boolean

Returns:

  • (Boolean)


202
203
204
205
206
207
208
# File 'lib/typhoeus/hydra.rb', line 202

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