Sha256: 80cef2a5388b61d66ae649be9942d598fa1552e4e3cc4525d26926054e36f2b3

Contents?: true

Size: 1.48 KB

Versions: 15

Compression:

Stored size: 1.48 KB

Contents

require File.expand_path(File.join(File.dirname(__FILE__), "helper"))

class ResponseCodeMechTest < Test::Unit::TestCase
  def setup
    @agent = WWW::Mechanize.new
  end

  def test_eof_error_loop
    assert_raises(EOFError) {
      @agent.get("http://localhost/http_headers?Content-Length=300")
    }
  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

15 entries across 15 versions & 5 rubygems

Version Path
eric-mechanize-0.9.3.20090623142847 test/test_response_code.rb
knu-mechanize-0.9.3.20090623142847 test/test_response_code.rb
tenderlove-mechanize-0.9.3.20090617085936 test/test_response_code.rb
tenderlove-mechanize-0.9.3.20090623142847 test/test_response_code.rb
mechanize-ntlm-0.9.1 test/test_response_code.rb
mechanize-0.8.0 test/test_response_code.rb
mechanize-0.8.1 test/test_response_code.rb
mechanize-0.8.4 test/test_response_code.rb
mechanize-0.8.2 test/test_response_code.rb
mechanize-0.8.3 test/test_response_code.rb
mechanize-0.8.5 test/test_response_code.rb
mechanize-0.9.0 test/test_response_code.rb
mechanize-0.9.2 test/test_response_code.rb
mechanize-0.9.3 test/test_response_code.rb
mechanize-0.9.1 test/test_response_code.rb