Class: Noumenon::Spec::ExampleApp
- Inherits:
-
Object
- Object
- Noumenon::Spec::ExampleApp
- Defined in:
- lib/noumenon/spec/example_app.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(options = {}) ⇒ ExampleApp
constructor
A new instance of ExampleApp.
- #respond(status, content) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ ExampleApp
Returns a new instance of ExampleApp.
4 5 6 |
# File 'lib/noumenon/spec/example_app.rb', line 4 def initialize( = {}) @options = { message: "This is a mounted application" }.merge(.symbolize_keys) end |
Instance Method Details
#call(env) ⇒ Object
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/noumenon/spec/example_app.rb', line 8 def call(env) case env["PATH_INFO"] when "/" respond 200, "<h1>#{@options[:message]}</h1>" when "/sub" respond 200, "<h1>This is a sub-page</h1>" else respond 404, "Page Not Found" end end |
#respond(status, content) ⇒ Object
19 20 21 |
# File 'lib/noumenon/spec/example_app.rb', line 19 def respond(status, content) [ status, { "Content-Type" => "text/html" }, StringIO.new(content) ] end |