Class: Typhoeus::HydraMock
- Inherits:
-
Object
- Object
- Typhoeus::HydraMock
- Defined in:
- lib/typhoeus/hydra.rb
Instance Attribute Summary collapse
-
#method ⇒ Object
readonly
Returns the value of attribute method.
-
#requests ⇒ Object
readonly
Returns the value of attribute requests.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
- #add_request(request) ⇒ Object
- #and_return(val) ⇒ Object
-
#initialize(url, method) ⇒ HydraMock
constructor
A new instance of HydraMock.
- #matches?(request) ⇒ Boolean
Constructor Details
#initialize(url, method) ⇒ HydraMock
Returns a new instance of HydraMock.
213 214 215 216 217 |
# File 'lib/typhoeus/hydra.rb', line 213 def initialize(url, method) @url = url @method = method @requests = [] end |
Instance Attribute Details
#method ⇒ Object (readonly)
Returns the value of attribute method.
211 212 213 |
# File 'lib/typhoeus/hydra.rb', line 211 def method @method end |
#requests ⇒ Object (readonly)
Returns the value of attribute requests.
211 212 213 |
# File 'lib/typhoeus/hydra.rb', line 211 def requests @requests end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
211 212 213 |
# File 'lib/typhoeus/hydra.rb', line 211 def response @response end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
211 212 213 |
# File 'lib/typhoeus/hydra.rb', line 211 def url @url end |
Instance Method Details
#add_request(request) ⇒ Object
219 220 221 |
# File 'lib/typhoeus/hydra.rb', line 219 def add_request(request) @requests << request end |
#and_return(val) ⇒ Object
223 224 225 |
# File 'lib/typhoeus/hydra.rb', line 223 def and_return(val) @response = val end |
#matches?(request) ⇒ Boolean
227 228 229 230 231 232 233 |
# File 'lib/typhoeus/hydra.rb', line 227 def matches?(request) if url.kind_of?(String) request.method == method && request.url == url else request.method == method && url =~ request.url end end |