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.



165
166
167
168
169
# File 'lib/typhoeus/hydra.rb', line 165

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

Instance Attribute Details

#methodObject (readonly)

Returns the value of attribute method.



163
164
165
# File 'lib/typhoeus/hydra.rb', line 163

def method
  @method
end

#requestsObject (readonly)

Returns the value of attribute requests.



163
164
165
# File 'lib/typhoeus/hydra.rb', line 163

def requests
  @requests
end

#responseObject (readonly)

Returns the value of attribute response.



163
164
165
# File 'lib/typhoeus/hydra.rb', line 163

def response
  @response
end

#urlObject (readonly)

Returns the value of attribute url.



163
164
165
# File 'lib/typhoeus/hydra.rb', line 163

def url
  @url
end

Instance Method Details

#add_request(request) ⇒ Object



171
172
173
# File 'lib/typhoeus/hydra.rb', line 171

def add_request(request)
  @requests << request
end

#and_return(val) ⇒ Object



175
176
177
# File 'lib/typhoeus/hydra.rb', line 175

def and_return(val)
  @response = val
end

#matches?(request) ⇒ Boolean

Returns:

  • (Boolean)


179
180
181
182
183
184
185
# File 'lib/typhoeus/hydra.rb', line 179

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