Sha256: 21a54bc48b0070911f3e6fb698d312db8e1e26e9f02d6c841375fd1ef2960c07

Contents?: true

Size: 1.42 KB

Versions: 3

Compression:

Stored size: 1.42 KB

Contents

require "helper"

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

  def test_post_with_bad_encoding_does_not_raise_exception
    @page  = @agent.get("http://localhost/test_bad_encoding.html")
    form = @page.form(:name => 'post_form1') { |f|
      f.first_name = "Aaron"
    }
    form.submit
  end

  def test_post_encoded_action
    form = @page.form(:name => '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

3 entries across 3 versions & 3 rubygems

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