mechanize 0.6.11 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of mechanize might be problematic. Click here for more details.
- data/CHANGELOG.txt +8 -0
- data/Manifest.txt +31 -22
- data/lib/mechanize.rb +2 -652
- data/lib/www/mechanize.rb +635 -0
- data/lib/www/mechanize/content_type_error.rb +16 -0
- data/lib/www/mechanize/cookie.rb +64 -0
- data/lib/{mechanize/cookie.rb → www/mechanize/cookie_jar.rb} +0 -60
- data/lib/www/mechanize/file.rb +73 -0
- data/lib/www/mechanize/file_saver.rb +39 -0
- data/lib/{mechanize → www/mechanize}/form.rb +119 -137
- data/lib/www/mechanize/form/button.rb +8 -0
- data/lib/www/mechanize/form/check_box.rb +13 -0
- data/lib/www/mechanize/form/field.rb +28 -0
- data/lib/www/mechanize/form/file_upload.rb +24 -0
- data/lib/www/mechanize/form/image_button.rb +23 -0
- data/lib/www/mechanize/form/multi_select_list.rb +69 -0
- data/lib/www/mechanize/form/option.rb +51 -0
- data/lib/www/mechanize/form/radio_button.rb +38 -0
- data/lib/www/mechanize/form/select_list.rb +41 -0
- data/lib/www/mechanize/headers.rb +12 -0
- data/lib/{mechanize → www/mechanize}/history.rb +0 -0
- data/lib/{mechanize → www/mechanize}/inspect.rb +21 -28
- data/lib/{mechanize → www/mechanize}/list.rb +0 -0
- data/lib/{mechanize → www/mechanize}/monkey_patch.rb +19 -0
- data/lib/www/mechanize/page.rb +121 -0
- data/lib/www/mechanize/page/base.rb +10 -0
- data/lib/www/mechanize/page/frame.rb +22 -0
- data/lib/www/mechanize/page/link.rb +50 -0
- data/lib/www/mechanize/page/meta.rb +10 -0
- data/lib/www/mechanize/pluggable_parsers.rb +93 -0
- data/lib/{mechanize/errors.rb → www/mechanize/response_code_error.rb} +1 -13
- data/test/{test_includes.rb → helper.rb} +4 -18
- data/test/{test_servlets.rb → servlets.rb} +0 -0
- data/test/tc_authenticate.rb +1 -8
- data/test/tc_bad_links.rb +3 -10
- data/test/tc_blank_form.rb +1 -8
- data/test/tc_checkboxes.rb +1 -8
- data/test/tc_cookie_class.rb +1 -6
- data/test/tc_cookie_jar.rb +1 -7
- data/test/tc_cookies.rb +10 -17
- data/test/tc_encoded_links.rb +5 -12
- data/test/tc_errors.rb +4 -11
- data/test/tc_follow_meta.rb +1 -8
- data/test/tc_form_action.rb +6 -14
- data/test/tc_form_as_hash.rb +1 -9
- data/test/tc_form_button.rb +5 -8
- data/test/tc_form_no_inputname.rb +1 -8
- data/test/tc_forms.rb +16 -24
- data/test/tc_frames.rb +3 -10
- data/test/tc_gzipping.rb +2 -9
- data/test/tc_history.rb +5 -12
- data/test/tc_html_unscape_forms.rb +8 -15
- data/test/tc_if_modified_since.rb +1 -6
- data/test/tc_keep_alive.rb +1 -8
- data/test/tc_links.rb +12 -19
- data/test/tc_mech.rb +26 -34
- data/test/{test_mechanize_file.rb → tc_mechanize_file.rb} +1 -6
- data/test/tc_multi_select.rb +10 -17
- data/test/tc_no_attributes.rb +1 -8
- data/test/tc_page.rb +3 -10
- data/test/tc_pluggable_parser.rb +8 -15
- data/test/tc_post_form.rb +3 -10
- data/test/tc_pretty_print.rb +3 -10
- data/test/tc_radiobutton.rb +2 -9
- data/test/tc_referer.rb +13 -20
- data/test/tc_relative_links.rb +1 -8
- data/test/tc_response_code.rb +14 -21
- data/test/tc_save_file.rb +1 -9
- data/test/tc_select.rb +3 -10
- data/test/tc_select_all.rb +2 -10
- data/test/tc_select_none.rb +2 -10
- data/test/tc_select_noopts.rb +2 -9
- data/test/tc_set_fields.rb +2 -9
- data/test/tc_ssl_server.rb +5 -12
- data/test/tc_subclass.rb +2 -9
- data/test/tc_textarea.rb +2 -9
- data/test/tc_upload.rb +2 -9
- data/test/test_all.rb +4 -43
- metadata +96 -80
- data/lib/mechanize/form_elements.rb +0 -254
- data/lib/mechanize/net-overrides/net/http.rb +0 -2107
- data/lib/mechanize/net-overrides/net/https.rb +0 -172
- data/lib/mechanize/net-overrides/net/protocol.rb +0 -380
- data/lib/mechanize/page.rb +0 -138
- data/lib/mechanize/page_elements.rb +0 -77
- data/lib/mechanize/parsers/rexml_page.rb +0 -35
- data/lib/mechanize/pluggable_parsers.rb +0 -204
- data/lib/mechanize/rexml.rb +0 -236
- data/setup.rb +0 -1585
- data/test/tc_proxy.rb +0 -25
- data/test/tc_watches.rb +0 -32
    
        data/test/tc_gzipping.rb
    CHANGED
    
    | @@ -1,13 +1,6 @@ | |
| 1 | 
            -
             | 
| 2 | 
            -
             | 
| 3 | 
            -
            require 'test/unit'
         | 
| 4 | 
            -
            require 'rubygems'
         | 
| 5 | 
            -
            require 'mechanize'
         | 
| 6 | 
            -
            require 'test_includes'
         | 
| 1 | 
            +
            require File.dirname(__FILE__) + "/helper"
         | 
| 7 2 |  | 
| 8 3 | 
             
            class TestGzip < Test::Unit::TestCase
         | 
| 9 | 
            -
              include TestMethods
         | 
| 10 | 
            -
             | 
| 11 4 | 
             
              def setup
         | 
| 12 5 | 
             
                @agent = WWW::Mechanize.new
         | 
| 13 6 | 
             
              end
         | 
| @@ -15,7 +8,7 @@ class TestGzip < Test::Unit::TestCase | |
| 15 8 | 
             
              def test_request_gzip
         | 
| 16 9 | 
             
                page = nil
         | 
| 17 10 | 
             
                assert_nothing_raised do
         | 
| 18 | 
            -
                  page = @agent.get("http://localhost | 
| 11 | 
            +
                  page = @agent.get("http://localhost/gzip?file=index.html")
         | 
| 19 12 | 
             
                end
         | 
| 20 13 | 
             
                assert_kind_of(WWW::Mechanize::Page, page)
         | 
| 21 14 | 
             
                assert_match('Hello World', page.body)
         | 
    
        data/test/tc_history.rb
    CHANGED
    
    | @@ -1,13 +1,6 @@ | |
| 1 | 
            -
             | 
| 2 | 
            -
             | 
| 3 | 
            -
            require 'test/unit'
         | 
| 4 | 
            -
            require 'rubygems'
         | 
| 5 | 
            -
            require 'mechanize'
         | 
| 6 | 
            -
            require 'test_includes'
         | 
| 1 | 
            +
            require File.dirname(__FILE__) + "/helper"
         | 
| 7 2 |  | 
| 8 3 | 
             
            class TestHistory < Test::Unit::TestCase
         | 
| 9 | 
            -
              include TestMethods
         | 
| 10 | 
            -
             | 
| 11 4 | 
             
              def setup
         | 
| 12 5 | 
             
                @agent    = WWW::Mechanize.new
         | 
| 13 6 | 
             
                @history  = WWW::Mechanize::History.new
         | 
| @@ -117,11 +110,11 @@ class TestHistory < Test::Unit::TestCase | |
| 117 110 | 
             
                page = @agent.get('http://localhost')
         | 
| 118 111 |  | 
| 119 112 | 
             
                node = Struct.new(:href, :inner_text).new('http://localhost/', 'blah')
         | 
| 120 | 
            -
                link = WWW::Mechanize::Link.new(node, nil, nil)
         | 
| 113 | 
            +
                link = WWW::Mechanize::Page::Link.new(node, nil, nil)
         | 
| 121 114 | 
             
                assert(@agent.visited?(link))
         | 
| 122 115 |  | 
| 123 116 | 
             
                node = Struct.new(:href, :inner_text).new('http://localhost', 'blah')
         | 
| 124 | 
            -
                link = WWW::Mechanize::Link.new(node, nil, nil)
         | 
| 117 | 
            +
                link = WWW::Mechanize::Page::Link.new(node, nil, nil)
         | 
| 125 118 | 
             
                assert(@agent.visited?(link))
         | 
| 126 119 | 
             
              end
         | 
| 127 120 |  | 
| @@ -129,11 +122,11 @@ class TestHistory < Test::Unit::TestCase | |
| 129 122 | 
             
                page = @agent.get('http://localhost/')
         | 
| 130 123 |  | 
| 131 124 | 
             
                node = Struct.new(:href, :inner_text).new('http://localhost/', 'blah')
         | 
| 132 | 
            -
                link = WWW::Mechanize::Link.new(node, nil, nil)
         | 
| 125 | 
            +
                link = WWW::Mechanize::Page::Link.new(node, nil, nil)
         | 
| 133 126 | 
             
                assert(@agent.visited?(link))
         | 
| 134 127 |  | 
| 135 128 | 
             
                node = Struct.new(:href, :inner_text).new('http://localhost', 'blah')
         | 
| 136 | 
            -
                link = WWW::Mechanize::Link.new(node, nil, nil)
         | 
| 129 | 
            +
                link = WWW::Mechanize::Page::Link.new(node, nil, nil)
         | 
| 137 130 | 
             
                assert(@agent.visited?(link))
         | 
| 138 131 | 
             
              end
         | 
| 139 132 |  | 
| @@ -1,45 +1,38 @@ | |
| 1 | 
            -
             | 
| 2 | 
            -
             | 
| 3 | 
            -
            require 'test/unit'
         | 
| 4 | 
            -
            require 'rubygems'
         | 
| 5 | 
            -
            require 'mechanize'
         | 
| 6 | 
            -
            require 'test_includes'
         | 
| 1 | 
            +
            require File.dirname(__FILE__) + "/helper"
         | 
| 7 2 |  | 
| 8 3 | 
             
            class TestCheckBoxes < Test::Unit::TestCase
         | 
| 9 | 
            -
              include TestMethods
         | 
| 10 | 
            -
             | 
| 11 4 | 
             
              def test_field
         | 
| 12 | 
            -
                f = WWW::Mechanize::Field.new('a&b', 'a&b')
         | 
| 5 | 
            +
                f = WWW::Mechanize::Form::Field.new('a&b', 'a&b')
         | 
| 13 6 | 
             
                assert_equal('a&b', f.name)
         | 
| 14 7 | 
             
                assert_equal('a&b', f.value)
         | 
| 15 8 |  | 
| 16 | 
            -
                f = WWW::Mechanize::Field.new('a&b', 'a&b')
         | 
| 9 | 
            +
                f = WWW::Mechanize::Form::Field.new('a&b', 'a&b')
         | 
| 17 10 | 
             
                assert_equal('a&b', f.name)
         | 
| 18 11 | 
             
                assert_equal('a&b', f.value)
         | 
| 19 12 |  | 
| 20 | 
            -
                f = WWW::Mechanize::Field.new('a&b', 'a&b')
         | 
| 13 | 
            +
                f = WWW::Mechanize::Form::Field.new('a&b', 'a&b')
         | 
| 21 14 | 
             
                assert_equal('a&b', f.name)
         | 
| 22 15 | 
             
                assert_equal('a&b', f.value)
         | 
| 23 16 | 
             
              end
         | 
| 24 17 |  | 
| 25 18 | 
             
              def test_file_upload
         | 
| 26 | 
            -
                f = WWW::Mechanize::FileUpload.new('a&b', 'a&b')
         | 
| 19 | 
            +
                f = WWW::Mechanize::Form::FileUpload.new('a&b', 'a&b')
         | 
| 27 20 | 
             
                assert_equal('a&b', f.name)
         | 
| 28 21 | 
             
                assert_equal('a&b', f.file_name)
         | 
| 29 22 |  | 
| 30 | 
            -
                f = WWW::Mechanize::FileUpload.new('a&b', 'a&b')
         | 
| 23 | 
            +
                f = WWW::Mechanize::Form::FileUpload.new('a&b', 'a&b')
         | 
| 31 24 | 
             
                assert_equal('a&b', f.name)
         | 
| 32 25 | 
             
                assert_equal('a&b', f.file_name)
         | 
| 33 26 | 
             
              end
         | 
| 34 27 |  | 
| 35 28 | 
             
              def test_image_button
         | 
| 36 | 
            -
                f = WWW::Mechanize::ImageButton.new('a&b', 'a&b')
         | 
| 29 | 
            +
                f = WWW::Mechanize::Form::ImageButton.new('a&b', 'a&b')
         | 
| 37 30 | 
             
                assert_equal('a&b', f.name)
         | 
| 38 31 | 
             
                assert_equal('a&b', f.value)
         | 
| 39 32 | 
             
              end
         | 
| 40 33 |  | 
| 41 34 | 
             
              def test_radio_button
         | 
| 42 | 
            -
                f = WWW::Mechanize::RadioButton.new('a&b', 'a&b', nil, nil)
         | 
| 35 | 
            +
                f = WWW::Mechanize::Form::RadioButton.new('a&b', 'a&b', nil, nil)
         | 
| 43 36 | 
             
                assert_equal('a&b', f.name)
         | 
| 44 37 | 
             
                assert_equal('a&b', f.value)
         | 
| 45 38 | 
             
              end
         | 
    
        data/test/tc_keep_alive.rb
    CHANGED
    
    | @@ -1,13 +1,6 @@ | |
| 1 | 
            -
             | 
| 2 | 
            -
             | 
| 3 | 
            -
            require 'test/unit'
         | 
| 4 | 
            -
            require 'rubygems'
         | 
| 5 | 
            -
            require 'mechanize'
         | 
| 6 | 
            -
            require 'test_includes'
         | 
| 1 | 
            +
            require File.dirname(__FILE__) + "/helper"
         | 
| 7 2 |  | 
| 8 3 | 
             
            class TestKeepAlive < Test::Unit::TestCase
         | 
| 9 | 
            -
              include TestMethods
         | 
| 10 | 
            -
             | 
| 11 4 | 
             
              def setup
         | 
| 12 5 | 
             
                @agent = WWW::Mechanize.new
         | 
| 13 6 | 
             
              end
         | 
    
        data/test/tc_links.rb
    CHANGED
    
    | @@ -1,13 +1,6 @@ | |
| 1 | 
            -
             | 
| 2 | 
            -
             | 
| 3 | 
            -
            require 'test/unit'
         | 
| 4 | 
            -
            require 'rubygems'
         | 
| 5 | 
            -
            require 'mechanize'
         | 
| 6 | 
            -
            require 'test_includes'
         | 
| 1 | 
            +
            require File.dirname(__FILE__) + "/helper"
         | 
| 7 2 |  | 
| 8 3 | 
             
            class LinksMechTest < Test::Unit::TestCase
         | 
| 9 | 
            -
              include TestMethods
         | 
| 10 | 
            -
             | 
| 11 4 | 
             
              def setup
         | 
| 12 5 | 
             
                @agent = WWW::Mechanize.new
         | 
| 13 6 | 
             
              end
         | 
| @@ -19,7 +12,7 @@ class LinksMechTest < Test::Unit::TestCase | |
| 19 12 | 
             
              end
         | 
| 20 13 |  | 
| 21 14 | 
             
              def test_find_meta
         | 
| 22 | 
            -
                page = @agent.get("http://localhost | 
| 15 | 
            +
                page = @agent.get("http://localhost/find_link.html")
         | 
| 23 16 | 
             
                assert_equal(3, page.meta.length)
         | 
| 24 17 | 
             
                assert_equal(%w{
         | 
| 25 18 | 
             
                  http://www.drphil.com/
         | 
| @@ -29,12 +22,12 @@ class LinksMechTest < Test::Unit::TestCase | |
| 29 22 | 
             
              end
         | 
| 30 23 |  | 
| 31 24 | 
             
              def test_find_link
         | 
| 32 | 
            -
                page = @agent.get("http://localhost | 
| 25 | 
            +
                page = @agent.get("http://localhost/find_link.html")
         | 
| 33 26 | 
             
                assert_equal(18, page.links.length)
         | 
| 34 27 | 
             
              end
         | 
| 35 28 |  | 
| 36 29 | 
             
              def test_alt_text
         | 
| 37 | 
            -
                page = @agent.get("http://localhost | 
| 30 | 
            +
                page = @agent.get("http://localhost/alt_text.html")
         | 
| 38 31 | 
             
                assert_equal(5, page.links.length)
         | 
| 39 32 | 
             
                assert_equal(1, page.meta.length)
         | 
| 40 33 |  | 
| @@ -48,27 +41,27 @@ class LinksMechTest < Test::Unit::TestCase | |
| 48 41 |  | 
| 49 42 | 
             
              def test_click_link
         | 
| 50 43 | 
             
                @agent.user_agent_alias = 'Mac Safari'
         | 
| 51 | 
            -
                page = @agent.get("http://localhost | 
| 44 | 
            +
                page = @agent.get("http://localhost/frame_test.html")
         | 
| 52 45 | 
             
                link = page.links.text("Form Test")
         | 
| 53 46 | 
             
                assert_not_nil(link)
         | 
| 54 47 | 
             
                assert_equal('Form Test', link.text)
         | 
| 55 48 | 
             
                page = @agent.click(link)
         | 
| 56 | 
            -
                assert_equal("http://localhost | 
| 49 | 
            +
                assert_equal("http://localhost/form_test.html",
         | 
| 57 50 | 
             
                  @agent.history.last.uri.to_s)
         | 
| 58 51 | 
             
              end
         | 
| 59 52 |  | 
| 60 53 | 
             
              def test_click_method
         | 
| 61 | 
            -
                page = @agent.get("http://localhost | 
| 54 | 
            +
                page = @agent.get("http://localhost/frame_test.html")
         | 
| 62 55 | 
             
                link = page.links.text("Form Test")
         | 
| 63 56 | 
             
                assert_not_nil(link)
         | 
| 64 57 | 
             
                assert_equal('Form Test', link.text)
         | 
| 65 58 | 
             
                page = link.click
         | 
| 66 | 
            -
                assert_equal("http://localhost | 
| 59 | 
            +
                assert_equal("http://localhost/form_test.html",
         | 
| 67 60 | 
             
                  @agent.history.last.uri.to_s)
         | 
| 68 61 | 
             
              end
         | 
| 69 62 |  | 
| 70 63 | 
             
              def test_find_bold_link
         | 
| 71 | 
            -
                page = @agent.get("http://localhost | 
| 64 | 
            +
                page = @agent.get("http://localhost/tc_links.html")
         | 
| 72 65 | 
             
                link = page.links.text(/Bold Dude/)
         | 
| 73 66 | 
             
                assert_equal(1, link.length)
         | 
| 74 67 | 
             
                assert_equal('Bold Dude', link.first.text)
         | 
| @@ -87,19 +80,19 @@ class LinksMechTest < Test::Unit::TestCase | |
| 87 80 | 
             
              end
         | 
| 88 81 |  | 
| 89 82 | 
             
              def test_link_with_encoded_space
         | 
| 90 | 
            -
                page = @agent.get("http://localhost | 
| 83 | 
            +
                page = @agent.get("http://localhost/tc_links.html")
         | 
| 91 84 | 
             
                link = page.links.text('encoded space').first
         | 
| 92 85 | 
             
                page = @agent.click link
         | 
| 93 86 | 
             
              end
         | 
| 94 87 |  | 
| 95 88 | 
             
              def test_link_with_space
         | 
| 96 | 
            -
                page = @agent.get("http://localhost | 
| 89 | 
            +
                page = @agent.get("http://localhost/tc_links.html")
         | 
| 97 90 | 
             
                link = page.links.text('not encoded space').first
         | 
| 98 91 | 
             
                page = @agent.click link
         | 
| 99 92 | 
             
              end
         | 
| 100 93 |  | 
| 101 94 | 
             
              def test_link_with_unusual_characters
         | 
| 102 | 
            -
                page = @agent.get("http://localhost | 
| 95 | 
            +
                page = @agent.get("http://localhost/tc_links.html")
         | 
| 103 96 | 
             
                link = page.links.text('unusual characters').first
         | 
| 104 97 | 
             
                assert_nothing_raised { @agent.click link }
         | 
| 105 98 | 
             
              end
         | 
    
        data/test/tc_mech.rb
    CHANGED
    
    | @@ -1,14 +1,6 @@ | |
| 1 | 
            -
             | 
| 2 | 
            -
             | 
| 3 | 
            -
            require 'webrick'
         | 
| 4 | 
            -
            require 'test/unit'
         | 
| 5 | 
            -
            require 'rubygems'
         | 
| 6 | 
            -
            require 'mechanize'
         | 
| 7 | 
            -
            require 'test_includes'
         | 
| 1 | 
            +
            require File.dirname(__FILE__) + "/helper"
         | 
| 8 2 |  | 
| 9 3 | 
             
            class TestMechMethods < Test::Unit::TestCase
         | 
| 10 | 
            -
              include TestMethods
         | 
| 11 | 
            -
             | 
| 12 4 | 
             
              def setup
         | 
| 13 5 | 
             
                @agent = WWW::Mechanize.new
         | 
| 14 6 | 
             
              end
         | 
| @@ -36,18 +28,18 @@ class TestMechMethods < Test::Unit::TestCase | |
| 36 28 | 
             
              def test_history
         | 
| 37 29 | 
             
                0.upto(25) do |i|
         | 
| 38 30 | 
             
                  assert_equal(i, @agent.history.size)
         | 
| 39 | 
            -
                  page = @agent.get("http://localhost | 
| 31 | 
            +
                  page = @agent.get("http://localhost/")
         | 
| 40 32 | 
             
                end
         | 
| 41 | 
            -
                page = @agent.get("http://localhost | 
| 33 | 
            +
                page = @agent.get("http://localhost/form_test.html")
         | 
| 42 34 |  | 
| 43 | 
            -
                assert_equal("http://localhost | 
| 35 | 
            +
                assert_equal("http://localhost/form_test.html",
         | 
| 44 36 | 
             
                  @agent.history.last.uri.to_s)
         | 
| 45 | 
            -
                assert_equal("http://localhost | 
| 37 | 
            +
                assert_equal("http://localhost/",
         | 
| 46 38 | 
             
                  @agent.history[-2].uri.to_s)
         | 
| 47 | 
            -
                assert_equal("http://localhost | 
| 39 | 
            +
                assert_equal("http://localhost/",
         | 
| 48 40 | 
             
                  @agent.history[-2].uri.to_s)
         | 
| 49 41 |  | 
| 50 | 
            -
                assert_equal(true, @agent.visited?("http://localhost | 
| 42 | 
            +
                assert_equal(true, @agent.visited?("http://localhost/"))
         | 
| 51 43 | 
             
                assert_equal(true, @agent.visited?("/form_test.html"))
         | 
| 52 44 | 
             
                assert_equal(false, @agent.visited?("http://google.com/"))
         | 
| 53 45 | 
             
                assert_equal(true, @agent.visited?(page.links.first))
         | 
| @@ -76,12 +68,12 @@ class TestMechMethods < Test::Unit::TestCase | |
| 76 68 | 
             
                @agent.max_history = 10
         | 
| 77 69 | 
             
                0.upto(10) do |i|
         | 
| 78 70 | 
             
                  assert_equal(i, @agent.history.size)
         | 
| 79 | 
            -
                  page = @agent.get("http://localhost | 
| 71 | 
            +
                  page = @agent.get("http://localhost/")
         | 
| 80 72 | 
             
                end
         | 
| 81 73 |  | 
| 82 74 | 
             
                0.upto(10) do |i|
         | 
| 83 75 | 
             
                  assert_equal(10, @agent.history.size)
         | 
| 84 | 
            -
                  page = @agent.get("http://localhost | 
| 76 | 
            +
                  page = @agent.get("http://localhost/")
         | 
| 85 77 | 
             
                end
         | 
| 86 78 | 
             
              end
         | 
| 87 79 |  | 
| @@ -105,24 +97,24 @@ class TestMechMethods < Test::Unit::TestCase | |
| 105 97 | 
             
              def test_back_button
         | 
| 106 98 | 
             
                0.upto(5) do |i|
         | 
| 107 99 | 
             
                  assert_equal(i, @agent.history.size)
         | 
| 108 | 
            -
                  page = @agent.get("http://localhost | 
| 100 | 
            +
                  page = @agent.get("http://localhost/")
         | 
| 109 101 | 
             
                end
         | 
| 110 | 
            -
                page = @agent.get("http://localhost | 
| 102 | 
            +
                page = @agent.get("http://localhost/form_test.html")
         | 
| 111 103 |  | 
| 112 | 
            -
                assert_equal("http://localhost | 
| 104 | 
            +
                assert_equal("http://localhost/form_test.html",
         | 
| 113 105 | 
             
                  @agent.history.last.uri.to_s)
         | 
| 114 | 
            -
                assert_equal("http://localhost | 
| 106 | 
            +
                assert_equal("http://localhost/",
         | 
| 115 107 | 
             
                  @agent.history[-2].uri.to_s)
         | 
| 116 108 |  | 
| 117 109 | 
             
                assert_equal(7, @agent.history.size)
         | 
| 118 110 | 
             
                @agent.back
         | 
| 119 111 | 
             
                assert_equal(6, @agent.history.size)
         | 
| 120 | 
            -
                assert_equal("http://localhost | 
| 112 | 
            +
                assert_equal("http://localhost/",
         | 
| 121 113 | 
             
                  @agent.history.last.uri.to_s)
         | 
| 122 114 | 
             
              end
         | 
| 123 115 |  | 
| 124 116 | 
             
              def test_google
         | 
| 125 | 
            -
                page = @agent.get("http://localhost | 
| 117 | 
            +
                page = @agent.get("http://localhost/google.html")
         | 
| 126 118 | 
             
                search = page.forms.find { |f| f.name == "f" }
         | 
| 127 119 | 
             
                assert_not_nil(search)
         | 
| 128 120 | 
             
                assert_not_nil(search.fields.name('q').first)
         | 
| @@ -132,36 +124,36 @@ class TestMechMethods < Test::Unit::TestCase | |
| 132 124 |  | 
| 133 125 | 
             
              def test_click
         | 
| 134 126 | 
             
                @agent.user_agent_alias = 'Mac Safari'
         | 
| 135 | 
            -
                page = @agent.get("http://localhost | 
| 127 | 
            +
                page = @agent.get("http://localhost/frame_test.html")
         | 
| 136 128 | 
             
                link = page.links.text("Form Test").first
         | 
| 137 129 | 
             
                assert_not_nil(link)
         | 
| 138 130 | 
             
                page = @agent.click(link)
         | 
| 139 | 
            -
                assert_equal("http://localhost | 
| 131 | 
            +
                assert_equal("http://localhost/form_test.html",
         | 
| 140 132 | 
             
                  @agent.history.last.uri.to_s)
         | 
| 141 133 | 
             
              end
         | 
| 142 134 |  | 
| 143 135 | 
             
              def test_click_hpricot
         | 
| 144 | 
            -
                page = @agent.get("http://localhost | 
| 136 | 
            +
                page = @agent.get("http://localhost/frame_test.html")
         | 
| 145 137 |  | 
| 146 138 | 
             
                link = (page/"a[@class=bar]").first
         | 
| 147 139 | 
             
                assert_not_nil(link)
         | 
| 148 140 | 
             
                page = @agent.click(link)
         | 
| 149 | 
            -
                assert_equal("http://localhost | 
| 141 | 
            +
                assert_equal("http://localhost/form_test.html",
         | 
| 150 142 | 
             
                  @agent.history.last.uri.to_s)
         | 
| 151 143 | 
             
              end
         | 
| 152 144 |  | 
| 153 145 | 
             
              def test_click_hpricot_frame
         | 
| 154 | 
            -
                page = @agent.get("http://localhost | 
| 146 | 
            +
                page = @agent.get("http://localhost/frame_test.html")
         | 
| 155 147 |  | 
| 156 148 | 
             
                link = (page/"frame[@name=frame2]").first
         | 
| 157 149 | 
             
                assert_not_nil(link)
         | 
| 158 150 | 
             
                page = @agent.click(link)
         | 
| 159 | 
            -
                assert_equal("http://localhost | 
| 151 | 
            +
                assert_equal("http://localhost/form_test.html",
         | 
| 160 152 | 
             
                  @agent.history.last.uri.to_s)
         | 
| 161 153 | 
             
              end
         | 
| 162 154 |  | 
| 163 155 | 
             
              def test_new_find
         | 
| 164 | 
            -
                page = @agent.get("http://localhost | 
| 156 | 
            +
                page = @agent.get("http://localhost/frame_test.html")
         | 
| 165 157 | 
             
                assert_equal(3, page.frames.size)
         | 
| 166 158 |  | 
| 167 159 | 
             
                find_orig = page.frames.find_all { |f| f.name == 'frame1' }
         | 
| @@ -175,18 +167,18 @@ class TestMechMethods < Test::Unit::TestCase | |
| 175 167 | 
             
              end
         | 
| 176 168 |  | 
| 177 169 | 
             
              def test_get_file
         | 
| 178 | 
            -
                page = @agent.get("http://localhost | 
| 170 | 
            +
                page = @agent.get("http://localhost/frame_test.html")
         | 
| 179 171 | 
             
                content_length = page.header['Content-Length']
         | 
| 180 | 
            -
                page_as_string = @agent.get_file("http://localhost | 
| 172 | 
            +
                page_as_string = @agent.get_file("http://localhost/frame_test.html")
         | 
| 181 173 | 
             
                assert_equal(content_length.to_i, page_as_string.length.to_i)
         | 
| 182 174 | 
             
              end
         | 
| 183 175 |  | 
| 184 176 | 
             
              def test_transact
         | 
| 185 | 
            -
                page = @agent.get("http://localhost | 
| 177 | 
            +
                page = @agent.get("http://localhost/frame_test.html")
         | 
| 186 178 | 
             
                assert_equal(1, @agent.history.length)
         | 
| 187 179 | 
             
                @agent.transact { |a|
         | 
| 188 180 | 
             
                  5.times {
         | 
| 189 | 
            -
                    @agent.get("http://localhost | 
| 181 | 
            +
                    @agent.get("http://localhost/frame_test.html")
         | 
| 190 182 | 
             
                  }
         | 
| 191 183 | 
             
                  assert_equal(6, @agent.history.length)
         | 
| 192 184 | 
             
                }
         | 
| @@ -1,9 +1,4 @@ | |
| 1 | 
            -
             | 
| 2 | 
            -
             | 
| 3 | 
            -
            require 'test/unit'
         | 
| 4 | 
            -
            require 'rubygems'
         | 
| 5 | 
            -
            require 'mechanize'
         | 
| 6 | 
            -
            require 'test_includes'
         | 
| 1 | 
            +
            require File.dirname(__FILE__) + "/helper"
         | 
| 7 2 |  | 
| 8 3 | 
             
            class MechanizeFileTest < Test::Unit::TestCase
         | 
| 9 4 | 
             
              def test_content_disposition
         | 
    
        data/test/tc_multi_select.rb
    CHANGED
    
    | @@ -1,19 +1,12 @@ | |
| 1 | 
            -
             | 
| 2 | 
            -
             | 
| 3 | 
            -
            require 'test/unit'
         | 
| 4 | 
            -
            require 'rubygems'
         | 
| 5 | 
            -
            require 'mechanize'
         | 
| 6 | 
            -
            require 'test_includes'
         | 
| 1 | 
            +
            require File.dirname(__FILE__) + "/helper"
         | 
| 7 2 |  | 
| 8 3 | 
             
            class MultiSelectTest < Test::Unit::TestCase
         | 
| 9 | 
            -
              include TestMethods
         | 
| 10 | 
            -
             | 
| 11 4 | 
             
              def setup
         | 
| 12 5 | 
             
                @agent = WWW::Mechanize.new
         | 
| 13 6 | 
             
              end
         | 
| 14 7 |  | 
| 15 8 | 
             
              def test_select_none
         | 
| 16 | 
            -
                page = @agent.get("http://localhost | 
| 9 | 
            +
                page = @agent.get("http://localhost/form_multi_select.html")
         | 
| 17 10 | 
             
                form = page.forms.first
         | 
| 18 11 | 
             
                form.fields.name('list').first.select_none
         | 
| 19 12 | 
             
                page = @agent.submit(form)
         | 
| @@ -21,7 +14,7 @@ class MultiSelectTest < Test::Unit::TestCase | |
| 21 14 | 
             
              end
         | 
| 22 15 |  | 
| 23 16 | 
             
              def test_select_all
         | 
| 24 | 
            -
                page = @agent.get("http://localhost | 
| 17 | 
            +
                page = @agent.get("http://localhost/form_multi_select.html")
         | 
| 25 18 | 
             
                form = page.forms.first
         | 
| 26 19 | 
             
                form.fields.name('list').first.select_all
         | 
| 27 20 | 
             
                page = @agent.submit(form)
         | 
| @@ -35,7 +28,7 @@ class MultiSelectTest < Test::Unit::TestCase | |
| 35 28 | 
             
              end
         | 
| 36 29 |  | 
| 37 30 | 
             
              def test_click_all
         | 
| 38 | 
            -
                page = @agent.get("http://localhost | 
| 31 | 
            +
                page = @agent.get("http://localhost/form_multi_select.html")
         | 
| 39 32 | 
             
                form = page.forms.first
         | 
| 40 33 | 
             
                form.fields.name('list').first.options.each { |o| o.click }
         | 
| 41 34 | 
             
                page = @agent.submit(form)
         | 
| @@ -48,7 +41,7 @@ class MultiSelectTest < Test::Unit::TestCase | |
| 48 41 | 
             
              end
         | 
| 49 42 |  | 
| 50 43 | 
             
              def test_select_default
         | 
| 51 | 
            -
                page = @agent.get("http://localhost | 
| 44 | 
            +
                page = @agent.get("http://localhost/form_multi_select.html")
         | 
| 52 45 | 
             
                form = page.forms.first
         | 
| 53 46 | 
             
                page = @agent.submit(form)
         | 
| 54 47 | 
             
                assert_equal(1, page.links.length)
         | 
| @@ -56,7 +49,7 @@ class MultiSelectTest < Test::Unit::TestCase | |
| 56 49 | 
             
              end
         | 
| 57 50 |  | 
| 58 51 | 
             
              def test_select_one
         | 
| 59 | 
            -
                page = @agent.get("http://localhost | 
| 52 | 
            +
                page = @agent.get("http://localhost/form_multi_select.html")
         | 
| 60 53 | 
             
                form = page.forms.first
         | 
| 61 54 | 
             
                form.list = 'Aaron'
         | 
| 62 55 | 
             
                assert_equal(['Aaron'], form.list)
         | 
| @@ -66,7 +59,7 @@ class MultiSelectTest < Test::Unit::TestCase | |
| 66 59 | 
             
              end
         | 
| 67 60 |  | 
| 68 61 | 
             
              def test_select_two
         | 
| 69 | 
            -
                page = @agent.get("http://localhost | 
| 62 | 
            +
                page = @agent.get("http://localhost/form_multi_select.html")
         | 
| 70 63 | 
             
                form = page.forms.first
         | 
| 71 64 | 
             
                form.list = ['1', 'Aaron']
         | 
| 72 65 | 
             
                page = @agent.submit(form)
         | 
| @@ -76,7 +69,7 @@ class MultiSelectTest < Test::Unit::TestCase | |
| 76 69 | 
             
              end
         | 
| 77 70 |  | 
| 78 71 | 
             
              def test_select_three
         | 
| 79 | 
            -
                page = @agent.get("http://localhost | 
| 72 | 
            +
                page = @agent.get("http://localhost/form_multi_select.html")
         | 
| 80 73 | 
             
                form = page.forms.first
         | 
| 81 74 | 
             
                form.list = ['1', '2', '3']
         | 
| 82 75 | 
             
                page = @agent.submit(form)
         | 
| @@ -87,7 +80,7 @@ class MultiSelectTest < Test::Unit::TestCase | |
| 87 80 | 
             
              end
         | 
| 88 81 |  | 
| 89 82 | 
             
              def test_select_three_twice
         | 
| 90 | 
            -
                page = @agent.get("http://localhost | 
| 83 | 
            +
                page = @agent.get("http://localhost/form_multi_select.html")
         | 
| 91 84 | 
             
                form = page.forms.first
         | 
| 92 85 | 
             
                form.list = ['1', '2', '3']
         | 
| 93 86 | 
             
                form.list = ['1', '2', '3']
         | 
| @@ -99,7 +92,7 @@ class MultiSelectTest < Test::Unit::TestCase | |
| 99 92 | 
             
              end
         | 
| 100 93 |  | 
| 101 94 | 
             
              def test_select_with_click
         | 
| 102 | 
            -
                page = @agent.get("http://localhost | 
| 95 | 
            +
                page = @agent.get("http://localhost/form_multi_select.html")
         | 
| 103 96 | 
             
                form = page.forms.first
         | 
| 104 97 | 
             
                form.list = ['1', 'Aaron']
         | 
| 105 98 | 
             
                form.fields.name('list').first.options[3].tick
         |