forked from sparklemotion/mechanize
/
test_form_action.rb
44 lines (39 loc) · 1.22 KB
/
test_form_action.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
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(: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