Class: WebConsole::Testing::FakeMiddleware
- Inherits:
-
Object
- Object
- WebConsole::Testing::FakeMiddleware
- Defined in:
- lib/web_console/testing/fake_middleware.rb
Constant Summary collapse
- DEFAULT_HEADERS =
{ "Content-Type" => "application/javascript" }
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(opts) ⇒ FakeMiddleware
constructor
A new instance of FakeMiddleware.
- #view ⇒ Object
Constructor Details
#initialize(opts) ⇒ FakeMiddleware
Returns a new instance of FakeMiddleware.
13 14 15 16 17 |
# File 'lib/web_console/testing/fake_middleware.rb', line 13 def initialize(opts) @headers = opts.fetch(:headers, DEFAULT_HEADERS) @req_path_regex = opts[:req_path_regex] @view_path = opts[:view_path] end |
Instance Method Details
#call(env) ⇒ Object
19 20 21 |
# File 'lib/web_console/testing/fake_middleware.rb', line 19 def call(env) [ 200, @headers, [ render(req_path(env)) ] ] end |
#view ⇒ Object
23 24 25 |
# File 'lib/web_console/testing/fake_middleware.rb', line 23 def view @view = View.new(@view_path) end |