Sha256: 9b9a1d2fc2261b550a68785a14d618ac9ea9bc518552b6a2890e11a537e3e873

Contents?: true

Size: 1.54 KB

Versions: 41

Compression:

Stored size: 1.54 KB

Contents

require 'mechanize/test_case'

class TestMechanizeFormTextarea < Mechanize::TestCase
  def setup
    super

    @page  = @mech.get("http://localhost/tc_textarea.html")
  end

  def test_empty_text_area
    form = @page.forms_with(:name => 'form1').first
    assert_equal('', form.field_with(:name => 'text1').value)
    form.text1 = 'Hello World'
    assert_equal('Hello World', form.field_with(:name => 'text1').value)
    page = @mech.submit(form)
    assert_equal(1, page.links.length)
    assert_equal('text1:Hello World', page.links[0].text)
  end

  def test_non_empty_textfield
    form = @page.forms_with(:name => 'form2').first
    assert_equal('sample text', form.field_with(:name => 'text1').value)
    page = @mech.submit(form)
    assert_equal(1, page.links.length)
    assert_equal('text1:sample text', page.links[0].text)
  end

  def test_multi_textfield
    form = @page.form_with(:name => 'form3')

    assert_equal(2, form.fields_with(:name => 'text1').length)
    assert_equal('', form.fields_with(:name => 'text1')[0].value)
    assert_equal('sample text', form.fields_with(:name => 'text1')[1].value)

    form.text1 = 'Hello World'

    assert_equal('Hello World', form.fields_with(:name => 'text1')[0].value)
    assert_equal('sample text', form.fields_with(:name => 'text1')[1].value)

    page = @mech.submit(form)

    assert_equal(2, page.links.length)

    link = page.links_with(:text => 'text1:sample text')

    assert_equal(1, link.length)

    link = page.links_with(:text => 'text1:Hello World')

    assert_equal(1, link.length)
  end
end

Version data entries

41 entries across 41 versions & 5 rubygems

Version Path
mechanize-2.10.0 test/test_mechanize_form_textarea.rb
mechanize-2.9.2 test/test_mechanize_form_textarea.rb
mechanize-2.9.1 test/test_mechanize_form_textarea.rb
mechanize-2.9.0 test/test_mechanize_form_textarea.rb
mechanize-2.8.5 test/test_mechanize_form_textarea.rb
mechanize-2.8.4 test/test_mechanize_form_textarea.rb
mechanize-2.8.3 test/test_mechanize_form_textarea.rb
mechanize-2.8.2 test/test_mechanize_form_textarea.rb
mechanize-2.8.1 test/test_mechanize_form_textarea.rb
mechanize-2.8.0 test/test_mechanize_form_textarea.rb
mechanize-2.7.7 test/test_mechanize_form_textarea.rb
husc-0.2.1 vendor/bundle/gems/mechanize-2.7.6/test/test_mechanize_form_textarea.rb
husc-0.2.0 vendor/bundle/gems/mechanize-2.7.6/test/test_mechanize_form_textarea.rb
husc-0.1.1 vendor/bundle/gems/mechanize-2.7.6/test/test_mechanize_form_textarea.rb
husc-0.1.0 vendor/bundle/gems/mechanize-2.7.6/test/test_mechanize_form_textarea.rb
mechanize-2.7.6 test/test_mechanize_form_textarea.rb
mechanize-2.7.5 test/test_mechanize_form_textarea.rb
mechanize-2.7.4 test/test_mechanize_form_textarea.rb
mechanize-2.7.3 test/test_mechanize_form_textarea.rb
mechanize-2.7.2 test/test_mechanize_form_textarea.rb