Sha256: aa20050924c416ffe84d8b62aad8a41523dcee3bbef6dd82ca90df8e849b0f7e

Contents?: true

Size: 1.21 KB

Versions: 7

Compression:

Stored size: 1.21 KB

Contents

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

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

  def test_post_encoded_action
    form = @page.form('post_form1') { |f|
      f.first_name = "Aaron"
    }
    assert_equal('/form_post?a=b&b=c', form.action)
    page = form.submit
    assert_equal("http://localhost/form_post?a=b&b=c", page.uri.to_s)
  end

  def test_get_encoded_action
    form = @page.form('post_form2') { |f|
      f.first_name = "Aaron"
    }
    assert_equal('/form_post?a=b&b=c', form.action)
    page = form.submit
    assert_equal("http://localhost/form_post?first_name=Aaron", page.uri.to_s)
  end

  def test_post_nonencoded_action
    form = @page.form('post_form3') { |f|
      f.first_name = "Aaron"
    }
    assert_equal('/form_post?a=b&b=c', form.action)
    page = form.submit
    assert_equal("http://localhost/form_post?a=b&b=c", page.uri.to_s)
  end

  def test_post_pound_sign
    form = @page.form('post_form4') { |f|
      f.first_name = "Aaron"
    }
    assert_equal('/form_post#1', form.action)
    page = form.submit
    assert_equal("http://localhost/form_post#1", page.uri.to_s)
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
mechanize-0.7.0 test/tc_form_action.rb
mechanize-0.7.1 test/tc_form_action.rb
mechanize-0.7.2 test/tc_form_action.rb
mechanize-0.7.3 test/tc_form_action.rb
mechanize-0.7.4 test/tc_form_action.rb
mechanize-0.7.5 test/tc_form_action.rb
mechanize-0.7.6 test/tc_form_action.rb