Sha256: e870a7f83a0361c5a7407f7fc67cfcd4f7c04f95280132de9178c1e6f43b7c65

Contents?: true

Size: 1.62 KB

Versions: 7

Compression:

Stored size: 1.62 KB

Contents

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

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

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

  def setup
    @agent = WWW::Mechanize.new
  end

  def test_dot_dot_slash
    @page = @agent.get("http://localhost/relative/tc_relative_links.html")
    page = @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.links.text('too many dots').click
    assert_not_nil(page)
    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")
    page = @agent.click(@page.frames.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")
    page1 = @agent.click @page.frames.name('frame1')
    assert_equal('http://localhost/relative/tc_relative_links.html', @agent.current_page.uri.to_s)
    page2 = @agent.click @page.frames.name('frame2')
    assert_equal('http://localhost/relative/tc_relative_links.html', @agent.current_page.uri.to_s)
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
mechanize-0.6.10 test/tc_relative_links.rb
mechanize-0.6.11 test/tc_relative_links.rb
mechanize-0.6.5 test/tc_relative_links.rb
mechanize-0.6.6 test/tc_relative_links.rb
mechanize-0.6.7 test/tc_relative_links.rb
mechanize-0.6.8 test/tc_relative_links.rb
mechanize-0.6.9 test/tc_relative_links.rb