Sha256: 1c27cbfc3670bde729659aaa151c1ee5b51165cf45af57e9f287c0465731fe0a

Contents?: true

Size: 1.15 KB

Versions: 2

Compression:

Stored size: 1.15 KB

Contents

require File.dirname(__FILE__) + "/helper"

class TestRedirectLimitReached < Test::Unit::TestCase
  include WWW

  def setup
    @agent = WWW::Mechanize.new
  end

  def test_to_s
    page = MechTestHelper.fake_page(@agent)
    error = Mechanize::RedirectLimitReachedError.new(page, 10)
    assert_match(/10/, error.to_s)
  end

  def test_get_default_redirects
    assert_raises(Mechanize::RedirectLimitReachedError) {
      begin
        @agent.get('http://localhost/infinite_redirect')
      rescue Mechanize::RedirectLimitReachedError => ex
        assert_equal(@agent.redirection_limit, ex.redirects)
        assert_equal("q=#{@agent.redirection_limit}", ex.page.uri.query)
        raise ex
      end
    }
  end

  def test_get_2_redirects
    @agent.redirection_limit = 2
    assert_raises(Mechanize::RedirectLimitReachedError) {
      begin
        @agent.get('http://localhost/infinite_redirect')
      rescue Mechanize::RedirectLimitReachedError => ex
        assert_equal(2, ex.redirects)
        assert_equal(@agent.redirection_limit, ex.redirects)
        assert_equal("q=#{@agent.redirection_limit}", ex.page.uri.query)
        raise ex
      end
    }
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mechanize-0.7.7 test/test_redirect_limit_reached.rb
mechanize-0.7.8 test/test_redirect_limit_reached.rb