Class: HttpStub::Models::Stub
- Inherits:
-
Object
- Object
- HttpStub::Models::Stub
- Defined in:
- lib/http_stub/models/stub.rb
Instance Attribute Summary collapse
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#parameters ⇒ Object
readonly
Returns the value of attribute parameters.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
Instance Method Summary collapse
-
#initialize(args) ⇒ Stub
constructor
A new instance of Stub.
- #method ⇒ Object
- #satisfies?(request) ⇒ Boolean
- #to_s ⇒ Object
Constructor Details
#initialize(args) ⇒ Stub
Returns a new instance of Stub.
8 9 10 11 12 13 14 |
# File 'lib/http_stub/models/stub.rb', line 8 def initialize(args) @args = args @uri = HttpStub::Models::StubUri.new(args["uri"]) @headers = HttpStub::Models::StubHeaders.new(args["headers"]) @parameters = HttpStub::Models::StubParameters.new(args["parameters"]) @response = HttpStub::Models::Response.new(args["response"]) end |
Instance Attribute Details
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
6 7 8 |
# File 'lib/http_stub/models/stub.rb', line 6 def headers @headers end |
#parameters ⇒ Object (readonly)
Returns the value of attribute parameters.
6 7 8 |
# File 'lib/http_stub/models/stub.rb', line 6 def parameters @parameters end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
6 7 8 |
# File 'lib/http_stub/models/stub.rb', line 6 def response @response end |
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
6 7 8 |
# File 'lib/http_stub/models/stub.rb', line 6 def uri @uri end |
Instance Method Details
#method ⇒ Object
23 24 25 |
# File 'lib/http_stub/models/stub.rb', line 23 def method @args["method"] end |
#satisfies?(request) ⇒ Boolean
16 17 18 19 20 21 |
# File 'lib/http_stub/models/stub.rb', line 16 def satisfies?(request) @uri.match?(request) && method.downcase == request.request_method.downcase && @headers.match?(request) && @parameters.match?(request) end |
#to_s ⇒ Object
27 28 29 |
# File 'lib/http_stub/models/stub.rb', line 27 def to_s @args.to_s end |