Class: Noumenon::Spec::ExampleApp

Inherits:
Object
  • Object
show all
Defined in:
lib/noumenon/spec/example_app.rb

Instance Method Summary collapse

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 = {})
  @options = { message: "This is a mounted application" }.merge(options.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