File: tc_form_button.rb

package info (click to toggle)
libwww-mechanize-ruby 0.7.6-2
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 752 kB
  • ctags: 607
  • sloc: ruby: 4,883; makefile: 4
file content (33 lines) | stat: -rw-r--r-- 848 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
require File.dirname(__FILE__) + "/helper"

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

  def test_submit_button
    html = <<-END
    <html><body>
    <form><input type="submit" value="submit" /></form>
    </body></html>
    END
    page = WWW::Mechanize::Page.new(  nil, html_response, html, 200, @agent )
    assert_equal(1, page.forms.length)
    assert_equal(1, page.forms.first.buttons.length)
  end

  def test_button_button
    html = <<-END
    <html><body>
    <form><input type="button" value="submit" /></form>
    </body></html>
    END
    page = WWW::Mechanize::Page.new(  nil, html_response, html, 200, @agent )
    assert_equal(1, page.forms.length)
    assert_equal(1, page.forms.first.buttons.length)
  end

  def html_response
    { 'content-type' => 'text/html' }
  end
end