test: add test harness with http and router tests
This commit is contained in:
1 parent
b8e3b2cd55
commit
c079abed00
6 files changed
+239
No files matched your search
@@ -0,0 +1,32 @@
|
||||
require 'minitest/autorun'
|
||||
require 'prism'
|
||||
|
||||
class ResponseTest < Minitest::Test
|
||||
def test_defaults
|
||||
status, headers, body = Prism::Response.new.finish
|
||||
assert_equal 200, status
|
||||
assert_equal 'text/html;charset=utf-8', headers['Content-Type']
|
||||
assert_equal [], body
|
||||
end
|
||||
|
||||
def test_write
|
||||
response = Prism::Response.new
|
||||
response << 'a'
|
||||
response.write('b')
|
||||
assert_equal %w[a b], response.finish[2]
|
||||
end
|
||||
|
||||
def test_set_cookie
|
||||
response = Prism::Response.new
|
||||
response.set_cookie('token', 'abc def')
|
||||
assert_includes response.headers['Set-Cookie'], 'token=abc+def'
|
||||
assert_includes response.headers['Set-Cookie'], 'HttpOnly'
|
||||
end
|
||||
|
||||
def test_multiple_cookies
|
||||
response = Prism::Response.new
|
||||
response.set_cookie('a', '1')
|
||||
response.set_cookie('b', '2')
|
||||
assert_equal 2, response.headers['Set-Cookie'].split("\n").size
|
||||
end
|
||||
end
|
||||
Reference in new issue
Block a user