class Ruter::Test

Public: A simple helper class to simulate requests to your application.

Examples

require "ruter"
require "ruter/test"

Ruter.define do
  root do
    res.write("hei")
  end
end

app = Ruter::Test.new
app.get("/")

app.res.status # => 200
app.res.body   # => "hei"

Attributes

app[R]

Internal: Returns the application class that handles the mock requests. Required by Ruter::Test::InstanceMethods.

Public Class Methods

new(app = Ruter) click to toggle source

Public: Initializes a new Ruter::Test object.

app - The application class to test (default: Ruter).

Examples

class API < Ruter
end

app = Ruter::Test.new(API)
app.get("/json")
# File lib/ruter/test.rb, line 34
def initialize(app = Ruter)
  @app = app
end