forked from sparklemotion/mechanize
/
test_relative_links.rb
40 lines (33 loc) · 1.45 KB
/
test_relative_links.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
require "helper"
class TestRelativeLinks < MiniTest::Unit::TestCase
def setup
@agent = Mechanize.new
end
def test_dot_dot_slash
@page = @agent.get("http://localhost/relative/tc_relative_links.html")
@page.links.first.click
assert_equal('http://localhost/tc_relative_links.html', @agent.current_page.uri.to_s)
end
def test_too_many_dots
@page = @agent.get("http://localhost/relative/tc_relative_links.html")
page = @page.link_with(:text => 'too many dots').click
assert_equal('http://localhost/tc_relative_links.html', page.uri.to_s)
end
def test_go_forward
@page = @agent.get("http://localhost/tc_relative_links.html")
@page = @page.links.first.click
assert_equal('http://localhost/relative/tc_relative_links.html', @agent.current_page.uri.to_s)
end
def test_frame_dot_dot_slash
@page = @agent.get("http://localhost/relative/tc_relative_links.html")
@agent.click(@page.frame_with(:text => 'frame1'))
assert_equal('http://localhost/tc_relative_links.html', @agent.current_page.uri.to_s)
end
def test_frame_forward_back_forward
@page = @agent.get("http://localhost/tc_relative_links.html")
@agent.click @page.frame_with(:name => 'frame1')
assert_equal('http://localhost/relative/tc_relative_links.html', @agent.current_page.uri.to_s)
@agent.click @page.frame_with(:name => 'frame2')
assert_equal('http://localhost/relative/tc_relative_links.html', @agent.current_page.uri.to_s)
end
end