mechanize 2.14.1 → 2.14.2

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.
Files changed (77) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +12 -1
  3. data/lib/mechanize/directory_saver.rb +2 -1
  4. data/lib/mechanize/file_saver.rb +2 -0
  5. data/lib/mechanize/parser.rb +33 -3
  6. data/lib/mechanize/test_case.rb +2 -9
  7. data/lib/mechanize/version.rb +1 -1
  8. metadata +3 -172
  9. data/.autotest +0 -6
  10. data/.github/dependabot.yml +0 -11
  11. data/.github/workflows/ci.yml +0 -43
  12. data/.github/workflows/upstream.yml +0 -51
  13. data/.gitignore +0 -15
  14. data/.yardopts +0 -8
  15. data/Gemfile +0 -12
  16. data/Rakefile +0 -56
  17. data/examples/flickr_upload.rb +0 -22
  18. data/examples/latest_user_agents.rb +0 -100
  19. data/examples/mech-dump.rb +0 -5
  20. data/examples/proxy_req.rb +0 -7
  21. data/examples/rubygems.rb +0 -23
  22. data/examples/spider.rb +0 -22
  23. data/examples/wikipedia_links_to_philosophy.rb +0 -158
  24. data/mechanize.gemspec +0 -74
  25. data/test/data/htpasswd +0 -1
  26. data/test/data/server.crt +0 -16
  27. data/test/data/server.csr +0 -12
  28. data/test/data/server.key +0 -15
  29. data/test/data/server.pem +0 -15
  30. data/test/test_mechanize.rb +0 -1382
  31. data/test/test_mechanize_cookie.rb +0 -559
  32. data/test/test_mechanize_cookie_jar.rb +0 -615
  33. data/test/test_mechanize_directory_saver.rb +0 -60
  34. data/test/test_mechanize_download.rb +0 -102
  35. data/test/test_mechanize_element_not_found_error.rb +0 -16
  36. data/test/test_mechanize_file.rb +0 -118
  37. data/test/test_mechanize_file_connection.rb +0 -40
  38. data/test/test_mechanize_file_request.rb +0 -26
  39. data/test/test_mechanize_file_response.rb +0 -48
  40. data/test/test_mechanize_file_saver.rb +0 -22
  41. data/test/test_mechanize_form.rb +0 -1025
  42. data/test/test_mechanize_form_check_box.rb +0 -49
  43. data/test/test_mechanize_form_encoding.rb +0 -110
  44. data/test/test_mechanize_form_field.rb +0 -78
  45. data/test/test_mechanize_form_file_upload.rb +0 -21
  46. data/test/test_mechanize_form_image_button.rb +0 -13
  47. data/test/test_mechanize_form_keygen.rb +0 -34
  48. data/test/test_mechanize_form_multi_select_list.rb +0 -98
  49. data/test/test_mechanize_form_option.rb +0 -60
  50. data/test/test_mechanize_form_radio_button.rb +0 -96
  51. data/test/test_mechanize_form_select_list.rb +0 -81
  52. data/test/test_mechanize_form_textarea.rb +0 -53
  53. data/test/test_mechanize_headers.rb +0 -36
  54. data/test/test_mechanize_history.rb +0 -104
  55. data/test/test_mechanize_http_agent.rb +0 -2145
  56. data/test/test_mechanize_http_auth_challenge.rb +0 -64
  57. data/test/test_mechanize_http_auth_realm.rb +0 -56
  58. data/test/test_mechanize_http_auth_store.rb +0 -233
  59. data/test/test_mechanize_http_content_disposition_parser.rb +0 -167
  60. data/test/test_mechanize_http_www_authenticate_parser.rb +0 -204
  61. data/test/test_mechanize_image.rb +0 -9
  62. data/test/test_mechanize_link.rb +0 -171
  63. data/test/test_mechanize_page.rb +0 -295
  64. data/test/test_mechanize_page_encoding.rb +0 -215
  65. data/test/test_mechanize_page_frame.rb +0 -17
  66. data/test/test_mechanize_page_image.rb +0 -191
  67. data/test/test_mechanize_page_link.rb +0 -377
  68. data/test/test_mechanize_page_meta_refresh.rb +0 -151
  69. data/test/test_mechanize_parser.rb +0 -316
  70. data/test/test_mechanize_pluggable_parser.rb +0 -68
  71. data/test/test_mechanize_redirect_limit_reached_error.rb +0 -25
  72. data/test/test_mechanize_redirect_not_get_or_head_error.rb +0 -15
  73. data/test/test_mechanize_response_read_error.rb +0 -29
  74. data/test/test_mechanize_subclass.rb +0 -23
  75. data/test/test_mechanize_util.rb +0 -144
  76. data/test/test_mechanize_xml_file.rb +0 -30
  77. data/test/test_multi_select.rb +0 -120
@@ -1,49 +0,0 @@
1
- # frozen_string_literal: true
2
- require 'mechanize/test_case'
3
-
4
- class TestMechanizeFormCheckBox < Mechanize::TestCase
5
-
6
- def setup
7
- super
8
-
9
- @page = @mech.get('http://localhost/tc_checkboxes.html')
10
- end
11
-
12
- def test_search
13
- form = @page.forms.first
14
-
15
- checkbox = form.checkbox_with(name: 'green')
16
- assert_equal('green', checkbox.name)
17
-
18
- assert_equal(checkbox, form.checkbox_with('green'))
19
- assert_equal(checkbox, form.checkbox_with(search: 'input[@type=checkbox][@name=green]'))
20
- end
21
-
22
- def test_check
23
- form = @page.forms.first
24
-
25
- form.checkbox_with(:name => 'green').check
26
-
27
- assert(form.checkbox_with(:name => 'green').checked)
28
-
29
- %w{ red blue yellow brown }.each do |color|
30
- assert_equal(false, form.checkbox_with(:name => color).checked)
31
- end
32
- end
33
-
34
- def test_uncheck
35
- form = @page.forms.first
36
-
37
- checkbox = form.checkbox_with(:name => 'green')
38
-
39
- checkbox.check
40
-
41
- assert form.checkbox_with(:name => 'green').checked
42
-
43
- checkbox.uncheck
44
-
45
- assert !form.checkbox_with(:name => 'green').checked
46
- end
47
-
48
- end
49
-
@@ -1,110 +0,0 @@
1
- # coding: utf-8
2
- # frozen_string_literal: true
3
- require 'mechanize/test_case'
4
-
5
- class TestMechanizeFormEncoding < Mechanize::TestCase
6
-
7
- # See also: tests of Util.from_native_charset
8
- # Encoding test should do with non-utf-8 characters
9
-
10
- INPUTTED_VALUE = "テスト" # "test" in Japanese UTF-8 encoding
11
- CONTENT_ENCODING = 'Shift_JIS' # one of Japanese encoding
12
- encoded_value = "\x83\x65\x83\x58\x83\x67".dup.force_encoding(::Encoding::SHIFT_JIS) # "test" in Japanese Shift_JIS encoding
13
- EXPECTED_QUERY = "first_name=#{CGI.escape(encoded_value)}&first_name=&gender=&green%5Beggs%5D="
14
-
15
- ENCODING_ERRORS = [EncodingError, Encoding::ConverterNotFoundError] # and so on
16
-
17
- ENCODING_LOG_MESSAGE = /INFO -- : form encoding: Shift_JIS/
18
- INVALID_ENCODING = 'UTF-eight'
19
-
20
- def set_form_with_encoding(enc)
21
- page = @mech.get("http://localhost/form_set_fields.html")
22
- form = page.forms.first
23
- form.encoding = enc
24
- form['first_name'] = INPUTTED_VALUE
25
- form
26
- end
27
-
28
- def test_form_encoding_returns_accept_charset
29
- page = @mech.get("http://localhost/rails_3_encoding_hack_form_test.html")
30
- form = page.forms.first
31
- accept_charset = form.form_node['accept-charset']
32
-
33
- assert accept_charset
34
- assert_equal accept_charset, form.encoding
35
- refute_equal page.encoding, form.encoding
36
- end
37
-
38
- def test_form_encoding_returns_page_encoding_when_no_accept_charset
39
- page = @mech.get("http://localhost/form_set_fields.html")
40
- form = page.forms.first
41
- accept_charset = form.form_node['accept-charset']
42
-
43
- assert_nil accept_charset
44
- refute_equal accept_charset, form.encoding
45
- assert_equal page.encoding, form.encoding
46
- end
47
-
48
- def test_form_encoding_equals_sets_new_encoding
49
- page = @mech.get("http://localhost/form_set_fields.html")
50
- form = page.forms.first
51
-
52
- refute_equal CONTENT_ENCODING, form.encoding
53
-
54
- form.encoding = CONTENT_ENCODING
55
-
56
- assert_equal CONTENT_ENCODING, form.encoding
57
- end
58
-
59
- def test_form_encoding_returns_nil_when_no_page_in_initialize
60
- # this sequence is seen at Mechanize#post(url, query_hash)
61
-
62
- node = {}
63
- # Create a fake form
64
- class << node
65
- def search(*args); []; end
66
- end
67
- node['method'] = 'POST'
68
- node['enctype'] = 'application/x-www-form-urlencoded'
69
- form = Mechanize::Form.new(node)
70
-
71
- assert_nil form.encoding
72
- end
73
-
74
- def test_post_form_with_form_encoding
75
- form = set_form_with_encoding CONTENT_ENCODING
76
- form.submit
77
-
78
- # we can not use "links.find{|l| l.text == 'key:val'}" assertion here
79
- # because the link text encoding is always UTF-8 regaredless of html encoding
80
- assert EXPECTED_QUERY, @mech.page.at('div#query').inner_text
81
- end
82
-
83
- def test_post_form_with_problematic_encoding
84
- form = set_form_with_encoding INVALID_ENCODING
85
-
86
- assert_raises(*ENCODING_ERRORS){ form.submit }
87
- end
88
-
89
- def test_form_ignore_encoding_error_is_true
90
- form = set_form_with_encoding INVALID_ENCODING
91
- form.ignore_encoding_error = true
92
-
93
- form.submit
94
-
95
- # HACK no assertions
96
- end
97
-
98
- def test_post_form_logs_form_encoding
99
- sio = StringIO.new
100
- @mech.log = Logger.new(sio)
101
- @mech.log.level = Logger::INFO
102
-
103
- form = set_form_with_encoding CONTENT_ENCODING
104
- form.submit
105
-
106
- assert_match ENCODING_LOG_MESSAGE, sio.string
107
-
108
- @mech.log = nil
109
- end
110
- end
@@ -1,78 +0,0 @@
1
- # frozen_string_literal: true
2
- require 'mechanize/test_case'
3
-
4
- class TestMechanizeFormField < Mechanize::TestCase
5
-
6
- def test_inspect
7
- field = node 'input'
8
- field = Mechanize::Form::Field.new field, 'a&b'
9
-
10
- assert_match "value: a&b", field.inspect
11
- end
12
-
13
- def test_name
14
- field = node 'input', 'name' => 'a&b'
15
- field = Mechanize::Form::Field.new field
16
-
17
- assert_equal 'a&b', field.name
18
- end
19
-
20
- def test_name_entity
21
- field = node 'input', 'name' => 'a&amp;b'
22
- field = Mechanize::Form::Field.new field
23
-
24
- assert_equal 'a&b', field.name
25
- end
26
-
27
- def test_name_entity_numeric
28
- field = node 'input', 'name' => 'a&#38;b'
29
- field = Mechanize::Form::Field.new field
30
-
31
- assert_equal 'a&b', field.name
32
- end
33
-
34
- def test_spaceship
35
- doc = Nokogiri::HTML::Document.new
36
- node = doc.create_element('input')
37
- node['name'] = 'foo'
38
- node['value'] = 'bar'
39
-
40
- a = Mechanize::Form::Field.new(node)
41
- b = Mechanize::Form::Field.new({'name' => 'foo'}, 'bar')
42
- c = Mechanize::Form::Field.new({'name' => 'foo'}, 'bar')
43
-
44
- assert_equal [a, b], [a, b].sort
45
- assert_equal [a, b], [b, a].sort
46
- assert_equal [b, c].sort, [b, c].sort
47
- end
48
-
49
- def test_value
50
- field = node 'input'
51
- field = Mechanize::Form::Field.new field, 'a&b'
52
-
53
- assert_equal 'a&b', field.value
54
- end
55
-
56
- def test_value_entity
57
- field = node 'input'
58
- field = Mechanize::Form::Field.new field, 'a&amp;b'
59
-
60
- assert_equal 'a&b', field.value
61
- end
62
-
63
- def test_value_entity_numeric
64
- field = node 'input'
65
- field = Mechanize::Form::Field.new field, 'a&#38;b'
66
-
67
- assert_equal 'a&b', field.value
68
- end
69
-
70
- def test_raw_value
71
- field = node 'input'
72
- field = Mechanize::Form::Field.new field, 'a&amp;b'
73
-
74
- assert_equal 'a&amp;b', field.raw_value
75
- end
76
-
77
- end
78
-
@@ -1,21 +0,0 @@
1
- # frozen_string_literal: true
2
- require 'mechanize/test_case'
3
-
4
- class TestMechanizeFormFileUpload < Mechanize::TestCase
5
-
6
- def test_file_name
7
- field = node 'input'
8
- field = Mechanize::Form::FileUpload.new field, 'a&b'
9
-
10
- assert_equal 'a&b', field.file_name
11
- end
12
-
13
- def test_file_name_entity
14
- field = node 'input'
15
- field = Mechanize::Form::FileUpload.new field, 'a&amp;b'
16
-
17
- assert_equal 'a&b', field.file_name
18
- end
19
-
20
- end
21
-
@@ -1,13 +0,0 @@
1
- # frozen_string_literal: true
2
- require 'mechanize/test_case'
3
-
4
- class TestMechanizeFormImageButton < Mechanize::TestCase
5
-
6
- def test_query_value
7
- button = Mechanize::Form::ImageButton.new 'name' => 'image_button'
8
-
9
- assert_equal [%w[image_button.x 0], %w[image_button.y 0]],
10
- button.query_value
11
- end
12
- end
13
-
@@ -1,34 +0,0 @@
1
- # frozen_string_literal: true
2
- require 'mechanize/test_case'
3
-
4
- class TestMechanizeFormKeygen < Mechanize::TestCase
5
-
6
- def setup
7
- super
8
-
9
- keygen = node('keygen',
10
- 'name' => 'userkey',
11
- 'challenge' => 'f4832e1d200df3df8c5c859edcabe52f')
12
-
13
- @keygen = Mechanize::Form::Keygen.new keygen
14
- end
15
-
16
- def test_challenge
17
- assert_equal "f4832e1d200df3df8c5c859edcabe52f", @keygen.challenge
18
- end
19
-
20
- def test_key
21
- assert @keygen.key.kind_of?(OpenSSL::PKey::PKey), "Not an OpenSSL key"
22
- assert @keygen.key.private?, "Not a private key"
23
- end
24
-
25
- def test_spki_signature
26
- skip("JRuby PKI doesn't handle this for reasons I've been unable to understand") if RUBY_ENGINE=~/jruby/
27
- spki = OpenSSL::Netscape::SPKI.new @keygen.value
28
- assert_equal @keygen.challenge, spki.challenge
29
- assert_equal @keygen.key.public_key.to_pem, spki.public_key.to_pem
30
- assert spki.verify(@keygen.key.public_key)
31
- end
32
-
33
- end
34
-
@@ -1,98 +0,0 @@
1
- # frozen_string_literal: true
2
- require 'mechanize/test_case'
3
-
4
- class TestMechanizeFormMultiSelectList < Mechanize::TestCase
5
-
6
- def setup
7
- super
8
-
9
- page = html_page <<-BODY
10
- <form name="form1" method="post" action="/form_post">
11
- <select name="select" multiple>
12
- <option value="1">Option 1</option>
13
- <option value="2" selected>Option 2</option>
14
- <option value="3">Option 3</option>
15
- <option value="4">Option 4</option>
16
- <option value="5">Option 5</option>
17
- <option value="6">Option 6</option>
18
- </select>
19
- </form>
20
- BODY
21
-
22
- form = page.forms.first
23
- @select = form.fields.first
24
- end
25
-
26
- def test_inspect
27
- assert_match "value: #{%w[2]}", @select.inspect
28
- end
29
-
30
- def test_inspect_select_all
31
- @select.select_all
32
- assert_match "value: #{%w[1 2 3 4 5 6]}", @select.inspect
33
- end
34
-
35
- def test_option_with
36
- option = @select.option_with value: '1'
37
-
38
- assert_equal '1', option.value
39
-
40
- option = @select.option_with search: 'option[@selected]'
41
-
42
- assert_equal '2', option.value
43
- end
44
-
45
- def test_options_with
46
- options = @select.options_with :value => /[12]/
47
-
48
- assert_equal 2, options.length
49
- end
50
-
51
- def test_query_value
52
- assert_equal [%w[select 2]], @select.query_value
53
-
54
- @select.options.last.click
55
-
56
- assert_equal [%w[select 2], %w[select 6]], @select.query_value
57
- end
58
-
59
- def test_query_value_empty
60
- @select.options.last.click
61
- @select.options.last.instance_variable_set :@value, ''
62
-
63
- assert_equal [%w[select 2], ['select', '']], @select.query_value
64
- end
65
-
66
- def test_select_all
67
- @select.select_all
68
-
69
- assert_equal %w[1 2 3 4 5 6], @select.value
70
- end
71
-
72
- def test_select_none
73
- @select.select_none
74
-
75
- assert_empty @select.value
76
- end
77
-
78
- def test_selected_options
79
- assert_equal [@select.options[1]], @select.selected_options
80
-
81
- @select.options.last.click
82
-
83
- assert_equal [@select.options[1], @select.options.last],
84
- @select.selected_options
85
- end
86
-
87
- def test_value
88
- assert_equal %w[2], @select.value
89
- end
90
-
91
- def test_value_equals
92
- @select.value = %w[a 1 2]
93
-
94
- assert_equal %w[a 1 2], @select.value
95
- end
96
-
97
- end
98
-
@@ -1,60 +0,0 @@
1
- # frozen_string_literal: true
2
- require 'mechanize/test_case'
3
-
4
- class TestMechanizeFormOption < Mechanize::TestCase
5
-
6
- def setup
7
- super
8
-
9
- page = html_page <<-BODY
10
- <form name="form1" method="post" action="/form_post">
11
- <select name="select">
12
- <option value="1">Option 1</option>
13
- <option value="2" selected>Option 2</option>
14
- </select>
15
- </form>
16
- BODY
17
-
18
- form = page.forms.first
19
- @select = form.fields.first
20
- @option1 = @select.options.first
21
- @option2 = @select.options.last
22
- end
23
-
24
- def test_inspect
25
- assert_match "value: 2", @select.inspect
26
- end
27
-
28
- def test_value_missing_value
29
- option = node 'option'
30
- option.inner_html = 'blah'
31
- option = Mechanize::Form::Option.new option, nil
32
-
33
- assert_equal 'blah', option.value
34
- end
35
-
36
- def test_click
37
- @option1.click
38
-
39
- assert @option1.selected?
40
- end
41
-
42
- def test_select
43
- @option1.select
44
-
45
- assert @option1.selected?
46
- end
47
-
48
- def test_unselect
49
- @option2.unselect
50
-
51
- refute @option2.selected?
52
- end
53
-
54
- def test_selected_eh
55
- refute @option1.selected?
56
- assert @option2.selected?
57
- end
58
-
59
- end
60
-
@@ -1,96 +0,0 @@
1
- # frozen_string_literal: true
2
- require 'mechanize/test_case'
3
-
4
- class TestMechanizeFormRadioButton < Mechanize::TestCase
5
-
6
- def setup
7
- super
8
-
9
- @page = html_page <<-BODY
10
- <form name="form1" method="post" action="/form_post">
11
- <label for="blue">Blue</label>
12
- <input type="radio" name="color" value="blue" id="blue">
13
- <input type="radio" name="color" value="brown">
14
- <input type="radio" name="color" value="green">
15
- <input type="radio" name="color" value="red">
16
- <input type="radio" name="color" value="yellow" id="a">
17
- <input type="radio" name="color" value="yellow" id="b">
18
-
19
- <input type="submit" value="Submit">
20
- </form>
21
- BODY
22
-
23
- @form = @page.forms.first
24
-
25
- @blue = @form.radiobutton_with :value => 'blue'
26
- @brown = @form.radiobutton_with :value => 'brown'
27
- @green = @form.radiobutton_with :value => 'green'
28
- @red = @form.radiobutton_with :value => 'red'
29
- @yellow = @form.radiobutton_with :id => 'a'
30
- end
31
-
32
- def test_check
33
- @blue.check
34
-
35
- assert @blue.checked?
36
- refute @brown.checked?
37
- refute @green.checked?
38
- refute @red.checked?
39
- refute @yellow.checked?
40
- end
41
-
42
- def test_check_multiple
43
- @blue.check
44
- @brown.check
45
-
46
- refute @blue.checked?
47
- assert @brown.checked?
48
- refute @green.checked?
49
- refute @red.checked?
50
- refute @yellow.checked?
51
- end
52
-
53
- def test_click
54
- @blue.click
55
-
56
- assert @blue.checked?
57
-
58
- @blue.click
59
-
60
- refute @blue.checked?
61
- end
62
-
63
- def test_equals2
64
- refute_equal @yellow, @red
65
-
66
- other_yellow = @form.radiobutton_with :id => 'b'
67
-
68
- assert_equal @yellow, other_yellow
69
- end
70
-
71
- def test_hash
72
- refute_equal @yellow.hash, @red.hash
73
-
74
- other_yellow = @form.radiobutton_with :id => 'b'
75
-
76
- assert_equal @yellow.hash, other_yellow.hash
77
- end
78
-
79
- def test_label
80
- assert_equal 'Blue', @blue.label.text
81
- end
82
-
83
- def test_uncheck
84
- @blue.check
85
-
86
- @blue.uncheck
87
-
88
- refute @blue.checked?
89
- refute @brown.checked?
90
- refute @green.checked?
91
- refute @red.checked?
92
- refute @yellow.checked?
93
- end
94
-
95
- end
96
-
@@ -1,81 +0,0 @@
1
- # frozen_string_literal: true
2
- require 'mechanize/test_case'
3
-
4
- class TestMechanizeFormSelectList < Mechanize::TestCase
5
-
6
- def setup
7
- super
8
-
9
- page = html_page <<-BODY
10
- <form name="form1" method="post" action="/form_post">
11
- <select name="select">
12
- <option value="1">Option 1</option>
13
- <option value="2" selected>Option 2</option>
14
- <option value="3">Option 3</option>
15
- <option value="4">Option 4</option>
16
- <option value="5">Option 5</option>
17
- <option value="6">Option 6</option>
18
- </select>
19
- </form>
20
- BODY
21
-
22
- form = page.forms.first
23
- @select = form.fields.first
24
- end
25
-
26
- def test_inspect
27
- assert_match "value: 2", @select.inspect
28
- end
29
-
30
- def test_option_with
31
- option = @select.option_with :value => '1'
32
-
33
- assert_equal '1', option.value
34
- end
35
-
36
- def test_options_with
37
- options = @select.options_with :value => /[12]/
38
-
39
- assert_equal 2, options.length
40
- end
41
-
42
- def test_query_value
43
- assert_equal [%w[select 2]], @select.query_value
44
-
45
- @select.select_all
46
-
47
- assert_equal [%w[select 6]], @select.query_value
48
- end
49
-
50
- def test_select_all
51
- @select.select_all
52
-
53
- assert_equal "6", @select.value
54
- end
55
-
56
- def test_select_none
57
- @select.select_none
58
-
59
- assert_equal "1", @select.value
60
- end
61
-
62
- def test_selected_options
63
- assert_equal [@select.options[1]], @select.selected_options
64
-
65
- @select.options.last.click
66
-
67
- assert_equal [@select.options.last], @select.selected_options
68
- end
69
-
70
- def test_value
71
- assert_equal "2", @select.value
72
- end
73
-
74
- def test_value_equals
75
- @select.value = %w[a 1 2]
76
-
77
- assert_equal "a", @select.value
78
- end
79
-
80
- end
81
-
@@ -1,53 +0,0 @@
1
- # frozen_string_literal: true
2
- require 'mechanize/test_case'
3
-
4
- class TestMechanizeFormTextarea < Mechanize::TestCase
5
- def setup
6
- super
7
-
8
- @page = @mech.get("http://localhost/tc_textarea.html")
9
- end
10
-
11
- def test_empty_text_area
12
- form = @page.forms_with(:name => 'form1').first
13
- assert_equal('', form.field_with(:name => 'text1').value)
14
- form.text1 = 'Hello World'
15
- assert_equal('Hello World', form.field_with(:name => 'text1').value)
16
- page = @mech.submit(form)
17
- assert_equal(1, page.links.length)
18
- assert_equal('text1:Hello World', page.links[0].text)
19
- end
20
-
21
- def test_non_empty_textfield
22
- form = @page.forms_with(:name => 'form2').first
23
- assert_equal('sample text', form.field_with(:name => 'text1').value)
24
- page = @mech.submit(form)
25
- assert_equal(1, page.links.length)
26
- assert_equal('text1:sample text', page.links[0].text)
27
- end
28
-
29
- def test_multi_textfield
30
- form = @page.form_with(:name => 'form3')
31
-
32
- assert_equal(2, form.fields_with(:name => 'text1').length)
33
- assert_equal('', form.fields_with(:name => 'text1')[0].value)
34
- assert_equal('sample text', form.fields_with(:name => 'text1')[1].value)
35
-
36
- form.text1 = 'Hello World'
37
-
38
- assert_equal('Hello World', form.fields_with(:name => 'text1')[0].value)
39
- assert_equal('sample text', form.fields_with(:name => 'text1')[1].value)
40
-
41
- page = @mech.submit(form)
42
-
43
- assert_equal(2, page.links.length)
44
-
45
- link = page.links_with(:text => 'text1:sample text')
46
-
47
- assert_equal(1, link.length)
48
-
49
- link = page.links_with(:text => 'text1:Hello World')
50
-
51
- assert_equal(1, link.length)
52
- end
53
- end