Class: Fake::RackApp
- Inherits:
-
Object
- Object
- Fake::RackApp
- Defined in:
- lib/fake_service.rb
Instance Method Summary collapse
- #add_request_handler(request_handler) ⇒ Object
- #call(env) ⇒ Object
- #clear_request_handlers ⇒ Object
-
#initialize ⇒ RackApp
constructor
A new instance of RackApp.
Constructor Details
#initialize ⇒ RackApp
Returns a new instance of RackApp.
59 60 61 |
# File 'lib/fake_service.rb', line 59 def initialize @handlers = [] end |
Instance Method Details
#add_request_handler(request_handler) ⇒ Object
63 64 65 |
# File 'lib/fake_service.rb', line 63 def add_request_handler(request_handler) @handlers << request_handler end |
#call(env) ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/fake_service.rb', line 71 def call(env) request = Fake::Request.new(env) # TODO: Make this part of rack stack Requests.add_request(request) @handlers.each do |handler| response = handler.call(request) return response if response end raise "NO HANDLER for #{request.path}" end |
#clear_request_handlers ⇒ Object
67 68 69 |
# File 'lib/fake_service.rb', line 67 def clear_request_handlers @handlers = [] end |