aboutsummaryrefslogtreecommitdiffstats
path: root/test/plum/client/test_response.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/plum/client/test_response.rb')
-rw-r--r--test/plum/client/test_response.rb50
1 files changed, 25 insertions, 25 deletions
diff --git a/test/plum/client/test_response.rb b/test/plum/client/test_response.rb
index 511a073..d3d4e42 100644
--- a/test/plum/client/test_response.rb
+++ b/test/plum/client/test_response.rb
@@ -4,49 +4,49 @@ using Plum::BinaryString
class ResponseTest < Minitest::Test
def test_finished
resp = Response.new
- resp._headers({})
+ resp.send(:set_headers, {})
assert_equal(false, resp.finished?)
- resp._finish
+ resp.send(:finish)
assert_equal(true, resp.finished?)
end
def test_fail
resp = Response.new
- resp._fail
- assert(true, resp.failed?)
+ resp.send(:fail, true)
+ assert(resp.failed?, "response must be failed")
end
def test_status
resp = Response.new
- resp._headers([
- [":status", "200"]
- ])
+ resp.send(:set_headers,
+ ":status" => "200"
+ )
assert_equal("200", resp.status)
end
def test_headers
resp = Response.new
- resp._headers([
- [":status", "200"],
- ["header", "abc"]
- ])
+ resp.send(:set_headers,
+ ":status" => "200",
+ "header" => "abc"
+ )
assert_equal("abc", resp[:HEADER])
end
def test_body
resp = Response.new
- resp._headers({})
- resp._chunk("a")
- resp._chunk("b")
- resp._finish
+ resp.send(:set_headers, {})
+ resp.send(:add_chunk, "a")
+ resp.send(:add_chunk, "b")
+ resp.send(:finish)
assert_equal("ab", resp.body)
end
def test_body_not_finished
resp = Response.new
- resp._headers({})
- resp._chunk("a")
- resp._chunk("b")
+ resp.send(:set_headers, {})
+ resp.send(:add_chunk, "a")
+ resp.send(:add_chunk, "b")
assert_raises { # TODO
resp.body
}
@@ -54,23 +54,23 @@ class ResponseTest < Minitest::Test
def test_on_chunk
resp = Response.new
- resp._headers({})
+ resp.send(:set_headers, {})
res = []
- resp._chunk("a")
- resp._chunk("b")
- resp._finish
+ resp.send(:add_chunk, "a")
+ resp.send(:add_chunk, "b")
+ resp.send(:finish)
resp.on_chunk { |chunk| res << chunk }
assert_equal(["a", "b"], res)
- resp._chunk("c")
+ resp.send(:add_chunk, "c")
assert_equal(["a", "b", "c"], res)
end
def test_on_finish
resp = Response.new
- resp._headers({})
+ resp.send(:set_headers, {})
ran = false
resp.on_finish { ran = true }
- resp._finish
+ resp.send(:finish)
assert(ran)
ran = false
resp.on_finish { ran = true }