Sha256: e8798a105b6b369afb52e16864caac79e9914f5057f96224570868c8e4c7f517
Contents?: true
Size: 1020 Bytes
Versions: 7
Compression:
Stored size: 1020 Bytes
Contents
test "hello" do Tynn.define do get do res.write("hello") end end app = Tynn::Test.new app.get("/") assert_equal 200, app.res.status assert_equal "hello", app.res.body end test "methods" do [:get, :post, :put, :patch, :delete].each do |method| Tynn.define do send(method) { res.write "" } end app = Tynn::Test.new app.send(method, "/") assert_equal 200, app.res.status end end test "captures" do Tynn.define do on :foo do |foo| on :bar do |bar| res.write(sprintf("%s:%s", foo, bar)) end end end app = Tynn::Test.new app.get("/foo/bar") assert_equal 200, app.res.status assert_equal "foo:bar", app.res.body end test "composition" do class Foo < Tynn end Foo.define do get do res.write(inbox[:foo]) end end Tynn.define do on "foo" do run(Foo, foo: 42) end end app = Tynn::Test.new app.get("/foo") assert_equal 200, app.res.status assert_equal "42", app.res.body end
Version data entries
7 entries across 7 versions & 1 rubygems