Sha256: bb74d9fbcc50803781291b2e9db058c360b7bd1991b1b3caf8b1a838fe6de0fc
Contents?: true
Size: 1.37 KB
Versions: 1
Compression:
Stored size: 1.37 KB
Contents
# frozen_string_literal: true require_relative "helper" class MiddlewareTest < Minitest::Test class Shrimp def initialize(app) @app = app end def call(env) status, headers, body = @app.call(env) [status, headers, body.reverse] end end def test_middleware_works app = Class.new(Tynn) app.use(Shrimp) app.define do get do res.write("1") res.write("2") end end ts = Tynn::Test.new(app) ts.get("/") assert_equal 200, ts.res.status assert_equal "21", ts.res.body end def test_middleware_with_composition app = Class.new(Tynn) api = Class.new(Tynn) app.use(Shrimp) app.define do on("api") do run(api) end end api.define do get do res.write("1") res.write("2") end end ts = Tynn::Test.new(app) ts.get("/api") assert_equal 200, ts.res.status assert_equal "21", ts.res.body end def test_middleware_for_sub_application app = Class.new(Tynn) api = Class.new(Tynn) api.use(Shrimp) app.define do on("api") do run(api) end end api.define do get do res.write("1") res.write("2") end end ts = Tynn::Test.new(app) ts.get("/api") assert_equal 200, ts.res.status assert_equal "21", ts.res.body end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
tynn-2.0.0.alpha | test/middleware_test.rb |