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