Sha256: 426c8be72949117afe1fba09edce02e180ad1db649d343a03e2aa59ad630fbd6
Contents?: true
Size: 931 Bytes
Versions: 1
Compression:
Stored size: 931 Bytes
Contents
# frozen_string_literal: true require_relative "helper" require_relative "../lib/tynn/json" class JSONTest < Minitest::Test def setup @app = Class.new(Tynn) end def test_respond_json_object @app.plugin(Tynn::JSON) @app.define do get do json(foo: "foo") end end ts = Tynn::Test.new(@app) ts.get("/") object = JSON.parse(ts.res.body) assert_equal "foo", object["foo"] end def test_respond_json_array @app.plugin(Tynn::JSON) @app.define do get do json(%w(foo bar baz)) end end ts = Tynn::Test.new(@app) ts.get("/") assert_equal %w(foo bar baz), JSON.parse(ts.res.body) end def test_content_type @app.plugin(Tynn::JSON) @app.define do get do json(ok: true) end end ts = Tynn::Test.new(@app) ts.get("/") assert_equal "application/json", ts.res.content_type end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
tynn-2.0.0.alpha | test/json_test.rb |