Sha256: 2ac2e4da3b437f274551544a4f742b28d6dcf5f694d1d5e0340481bd72f123f0

Contents?: true

Size: 1.39 KB

Versions: 9

Compression:

Stored size: 1.39 KB

Contents

$:.unshift File.join(File.dirname(__FILE__), "..", "lib")

require 'test/unit'
require 'rubygems'
require 'mechanize'
require 'test_includes'
require 'logger'

class TestFormAction < Test::Unit::TestCase
  include TestMethods

  def setup
    @agent = WWW::Mechanize.new
    @page  = @agent.get("http://localhost:#{PORT}/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:#{PORT}/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:#{PORT}/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:#{PORT}/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:#{PORT}/form_post#1", page.uri.to_s)
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
mechanize-0.6.10 test/tc_form_action.rb
mechanize-0.6.3 test/tc_form_action.rb
mechanize-0.6.7 test/tc_form_action.rb
mechanize-0.6.4 test/tc_form_action.rb
mechanize-0.6.11 test/tc_form_action.rb
mechanize-0.6.6 test/tc_form_action.rb
mechanize-0.6.8 test/tc_form_action.rb
mechanize-0.6.5 test/tc_form_action.rb
mechanize-0.6.9 test/tc_form_action.rb