Sha256: b2b2d9de9bc9ac262526fe7bc8942c6733a557401d3b872e78c667f4e03e3e0b
Contents?: true
Size: 1.32 KB
Versions: 9
Compression:
Stored size: 1.32 KB
Contents
require File.dirname(__FILE__) + "/helper" class ResponseCodeMechTest < Test::Unit::TestCase def setup @agent = WWW::Mechanize.new end def test_redirect @agent.get("http://localhost/response_code?code=300") assert_equal("http://localhost/index.html", @agent.current_page.uri.to_s) @agent.get("http://localhost/response_code?code=301") assert_equal("http://localhost/index.html", @agent.current_page.uri.to_s) @agent.get("http://localhost/response_code?code=302") assert_equal("http://localhost/index.html", @agent.current_page.uri.to_s) @agent.get("http://localhost/response_code?code=303") assert_equal("http://localhost/index.html", @agent.current_page.uri.to_s) @agent.get("http://localhost/response_code?code=307") assert_equal("http://localhost/index.html", @agent.current_page.uri.to_s) end def test_do_not_follow_redirect @agent.redirect_ok = false @agent.get("http://localhost/response_code?code=302") assert_equal("http://localhost/response_code?code=302", @agent.current_page.uri.to_s) end def test_error @agent = WWW::Mechanize.new begin @agent.get("http://localhost/response_code?code=500") rescue WWW::Mechanize::ResponseCodeError => err assert_equal("500", err.response_code) end end end
Version data entries
9 entries across 9 versions & 1 rubygems