Sha256: 3b57056120874613a8b0ca7b7f5120686bd2044b2169cb13c7a547419b76cf37

Contents?: true

Size: 1.2 KB

Versions: 10

Compression:

Stored size: 1.2 KB

Contents

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

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

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

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

  def test_bad_form_method
    page = @agent.get("http://localhost:#{PORT}/bad_form_test.html")
    assert_raise(RuntimeError) {
      @agent.submit(page.forms.first)
    }
  end

  def test_non_exist
    begin
      page = @agent.get("http://localhost:#{PORT}/bad_form_test.html")
    rescue RuntimeError => ex
      assert_equal("404", ex.inspect)
    end
  end

  def test_too_many_radio
    page = @agent.get("http://localhost:#{PORT}/form_test.html")
    form = page.forms.name('post_form1').first
    form.radiobuttons.each { |r| r.checked = true }
    assert_raise(RuntimeError) {
      @agent.submit(form)
    }
  end

  def test_unknown_agent
    assert_raise(RuntimeError) {
      @agent.user_agent_alias = "Aaron's Browser"
    }
  end

  def test_bad_url
    assert_raise(RuntimeError) {
      @agent.get('/foo.html')
    }
  end

  def test_unsupported_scheme
    assert_raise(RuntimeError) {
      @agent.get('ftp://server.com/foo.html')
    }
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
mechanize-0.6.10 test/tc_errors.rb
mechanize-0.6.3 test/tc_errors.rb
mechanize-0.6.11 test/tc_errors.rb
mechanize-0.6.2 test/tc_errors.rb
mechanize-0.6.4 test/tc_errors.rb
mechanize-0.6.5 test/tc_errors.rb
mechanize-0.6.6 test/tc_errors.rb
mechanize-0.6.7 test/tc_errors.rb
mechanize-0.6.8 test/tc_errors.rb
mechanize-0.6.9 test/tc_errors.rb