Sha256: a9fc3ba1cc4556a14543008af8ea3635ba21b2dcc1b7a3d0de3f6b54ef790c5a

Contents?: true

Size: 967 Bytes

Versions: 2

Compression:

Stored size: 967 Bytes

Contents

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

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

  def test_submit_input_tag
    assert_form_contains_button('<input type="submit" value="submit" />')
  end

  def test_button_input_tag
    assert_form_contains_button('<input type="button" value="submit" />')
  end

  def test_submit_button_tag
    assert_form_contains_button('<button type="submit" value="submit"/>')
  end

  def test_button_button_tag
    assert_form_contains_button('<button type="button" value="submit"/>')
  end

  def assert_form_contains_button(button)
    page = Mechanize::Page.new(nil, html_response, html(button), 200, @agent)
    assert_equal(1, page.forms.length)
    assert_equal(1, page.forms.first.buttons.length)
  end

  def html(input)
    "<html><body><form>#{input}</form></body></html>"
  end

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

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
kitamomonga-mechanize-0.9.3.20090724215219 test/test_form_button.rb
tenderlove-mechanize-0.9.3.20090911221705 test/test_form_button.rb