Sha256: 1b1b279214ad9f387461b3d4434c4488f6b2de22e56548bc158c9ac0b57735c6

Contents?: true

Size: 1.16 KB

Versions: 3

Compression:

Stored size: 1.16 KB

Contents

require "helper"

class TestFormButtons < MiniTest::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 test_image_button_tag
    assert_form_contains_button('<input type="image" name="submit" src="http://foo.com/image.jpg"/>')
  end
  
  def test_no_name_image_button_tag
    assert_form_contains_button('<input type="image" src="http://foo.com/image.jpg"/>')
  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

3 entries across 3 versions & 3 rubygems

Version Path
aai10-mechanize-2.0.1.0 test/test_form_button.rb
neocoin-mechanize-2.0.2 test/test_form_button.rb
mechanize-2.0.1 test/test_form_button.rb