Sha256: 1b06838dc16e238f50ee54b0ebe4288df71a31d04bd9d5822b63687d8c123db5

Contents?: true

Size: 1.02 KB

Versions: 3

Compression:

Stored size: 1.02 KB

Contents

require "helper"

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

  def test_post_form
    page = @agent.post("http://localhost/form_post",
                        'gender' => 'female'
                      )
    assert_not_nil(
      page.links.find { |l| l.text == "gender:female" },
      "gender field missing"
    )
  end

  def test_post_form_json
    page = @agent.post "http://localhost/form_post",
                       'json' => '["&quot;"]'

    assert page.links.find { |l| l.text == 'json:["""]' }
  end

  def test_post_form_multival
    page = @agent.post("http://localhost/form_post",
                       [ ['gender', 'female'],
                         ['gender', 'male']
                       ]
                      )
    assert_not_nil(
      page.links.find { |l| l.text == "gender:female" },
      "gender field missing"
    )
    assert_not_nil(
      page.links.find { |l| l.text == "gender:male" },
      "gender field missing"
    )
    assert_equal(2, page.links.length)
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
mechanize-2.0 test/test_post_form.rb
mechanize-2.0.pre.2 test/test_post_form.rb
mechanize-2.0.pre.1 test/test_post_form.rb