提交 dbb0abfb 编写于 作者: J Joshua Peek

More integration test coverage

上级 f2456584
......@@ -265,6 +265,10 @@ def cookie_monster
cookies["cookie_3"] = "chocolate"
render :text => "Gone", :status => 410
end
def redirect
redirect_to :action => "get"
end
end
def test_get
......@@ -274,6 +278,9 @@ def test_get
assert_equal "OK", status_message
assert_equal "200 OK", response.headers["Status"]
assert_equal ["200 OK"], headers["status"]
assert_response 200
assert_response :success
assert_response :ok
assert_equal [], response.headers["cookie"]
assert_equal [], headers["cookie"]
assert_equal({}, cookies)
......@@ -290,6 +297,9 @@ def test_post
assert_equal "Created", status_message
assert_equal "201 Created", response.headers["Status"]
assert_equal ["201 Created"], headers["status"]
assert_response 201
assert_response :success
assert_response :created
assert_equal [], response.headers["cookie"]
assert_equal [], headers["cookie"]
assert_equal({}, cookies)
......@@ -308,6 +318,8 @@ def test_cookie_monster
assert_equal "Gone", status_message
assert_equal "410 Gone", response.headers["Status"]
assert_equal ["410 Gone"], headers["status"]
assert_response 410
assert_response :gone
assert_equal nil, response.headers["Set-Cookie"]
assert_equal ["cookie_1=; path=/", "cookie_3=chocolate; path=/"], headers['set-cookie']
assert_equal [[], ["chocolate"]], response.headers["cookie"]
......@@ -317,14 +329,28 @@ def test_cookie_monster
end
end
def test_redirect
with_test_route_set do
get '/redirect'
assert_equal 302, status
assert_equal "Found", status_message
assert_equal "302 Found", response.headers["Status"]
assert_equal ["302 Found"], headers["status"]
assert_response 302
assert_response :redirect
assert_response :found
assert_equal "<html><body>You are being <a href=\"http://www.example.com/get\">redirected</a>.</body></html>", response.body
assert_kind_of HTML::Document, html_document
assert_equal 1, request_count
end
end
private
def with_test_route_set
with_routing do |set|
set.draw do |map|
map.with_options :controller => "IntegrationProcessTest::Integration" do |c|
c.connect '/get', :action => "get"
c.connect '/post', :action => "post"
c.connect '/cookie_monster', :action => "cookie_monster"
c.connect "/:action"
end
end
yield
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册