Class: Tynn::Test

Inherits:
Object
  • Object
show all
Includes:
InstanceMethods
Defined in:
lib/tynn/test.rb

Overview

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

Examples

require "tynn"
require "tynn/test"

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

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

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

Defined Under Namespace

Modules: InstanceMethods

Instance Method Summary collapse

Methods included from InstanceMethods

#delete, #get, #head, #options, #patch, #post, #put, #req, #res

Constructor Details

#initialize(app = Tynn) ⇒ Test

Public: Initializes a new Tynn::Test object.

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

Examples

class API < Tynn
end

app = Tynn::Test.new(API)
app.get("/json")


34
35
36
# File 'lib/tynn/test.rb', line 34

def initialize(app = Tynn)
  @app = app
end

Instance Method Details

#appObject

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



40
41
42
# File 'lib/tynn/test.rb', line 40

def app
  return @app
end