Sha256: 1a06533c44c5c1d5444c7a849349b4db09ff6cee4c1c0c2bb13027cb078489f2

Contents?: true

Size: 1.5 KB

Versions: 9

Compression:

Stored size: 1.5 KB

Contents

require File.dirname(__FILE__) + "/helper"

class TestTextArea < Test::Unit::TestCase
  def setup
    @agent = WWW::Mechanize.new
    @page  = @agent.get("http://localhost/tc_textarea.html")
  end

  def test_empty_text_area
    form = @page.forms.name('form1').first
    assert_equal('', form.fields.name('text1').value)
    form.text1 = 'Hello World'
    assert_equal('Hello World', form.fields.name('text1').value)
    page = @agent.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.name('form2').first
    assert_equal('sample text', form.fields.name('text1').value)
    page = @agent.submit(form)
    assert_equal(1, page.links.length)
    assert_equal('text1:sample text', page.links[0].text)
  end

  def test_multi_textfield
    form = @page.forms.name('form3').first
    assert_equal(2, form.fields.name('text1').length)
    assert_equal('', form.fields.name('text1')[0].value)
    assert_equal('sample text', form.fields.name('text1')[1].value)
    form.text1 = 'Hello World'
    assert_equal('Hello World', form.fields.name('text1')[0].value)
    assert_equal('sample text', form.fields.name('text1')[1].value)
    page = @agent.submit(form)
    assert_equal(2, page.links.length)
    link = page.links.text('text1:sample text')
    assert_not_nil(link)
    assert_equal(1, link.length)

    link = page.links.text('text1:Hello World')
    assert_not_nil(link)
    assert_equal(1, link.length)
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
mechanize-0.7.3 test/tc_textarea.rb
mechanize-0.7.5 test/tc_textarea.rb
mechanize-0.7.0 test/tc_textarea.rb
mechanize-0.7.1 test/tc_textarea.rb
mechanize-0.7.2 test/tc_textarea.rb
mechanize-0.7.4 test/tc_textarea.rb
mechanize-0.7.6 test/tc_textarea.rb
mechanize-0.7.7 test/test_textarea.rb
mechanize-0.7.8 test/test_textarea.rb