Sha256: d0f0301f4bf6a16f966a47ba20050146d15e79bcfefdbc5b9bb392cbea429efc

Contents?: true

Size: 885 Bytes

Versions: 6

Compression:

Stored size: 885 Bytes

Contents

$:.unshift File.join(File.dirname(__FILE__), "..", "lib")

require 'test/unit'
require 'rubygems'
require 'mechanize'
require 'test_includes'

class ResponseCodeMechTest < Test::Unit::TestCase
  include TestMethods

  def test_redirect
    agent = WWW::Mechanize.new { |a| a.log = Logger.new(nil) }
    agent.get("http://localhost:#{@port}/response_code?code=301")
    assert_equal("http://localhost:#{@port}/index.html",
      agent.current_page.uri.to_s)

    agent.get("http://localhost:#{@port}/response_code?code=302")
    assert_equal("http://localhost:#{@port}/index.html",
      agent.current_page.uri.to_s)
  end

  def test_error
    agent = WWW::Mechanize.new { |a| a.log = Logger.new(nil) }
    begin
      agent.get("http://localhost:#{@port}/response_code?code=500")
    rescue WWW::ResponseCodeError => err
      assert_equal("500", err.response_code)
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
mechanize-0.4.5 test/tc_response_code.rb
mechanize-0.4.3 test/tc_response_code.rb
mechanize-0.4.4 test/tc_response_code.rb
mechanize-0.4.7 test/tc_response_code.rb
mechanize-0.4.2 test/tc_response_code.rb
mechanize-0.4.6 test/tc_response_code.rb