Sha256: dcc0a7e55716a8ad940ab57a34e714b337b4c61a570f334d17be33ee23d75a9c

Contents?: true

Size: 1.11 KB

Versions: 10

Compression:

Stored size: 1.11 KB

Contents

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

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

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

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

  def test_too_many_radio
    page = @agent.get("http://localhost/form_test.html")
    form = page.form_with(:name => 'post_form1')
    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(WWW::Mechanize::UnsupportedSchemeError) {
      @agent.get('ftp://server.com/foo.html')
    }
  end
end

Version data entries

10 entries across 10 versions & 5 rubygems

Version Path
eric-mechanize-0.9.3.20090623142847 test/test_errors.rb
knu-mechanize-0.9.3.20090623142847 test/test_errors.rb
tenderlove-mechanize-0.9.3.20090617085936 test/test_errors.rb
tenderlove-mechanize-0.9.3.20090623142847 test/test_errors.rb
mechanize-ntlm-0.9.1 test/test_errors.rb
mechanize-0.9.0 test/test_errors.rb
mechanize-0.8.5 test/test_errors.rb
mechanize-0.9.2 test/test_errors.rb
mechanize-0.9.1 test/test_errors.rb
mechanize-0.9.3 test/test_errors.rb