Sha256: 3596fff36214d0c21876be00b3f6359715152cd6a6d9685daa0d76f65500967c

Contents?: true

Size: 1.5 KB

Versions: 9

Compression:

Stored size: 1.5 KB

Contents

require File.dirname(__FILE__) + "/helper"

class TestRelativeLinks < Test::Unit::TestCase
  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

9 entries across 9 versions & 1 rubygems

Version Path
mechanize-0.7.3 test/tc_relative_links.rb
mechanize-0.7.1 test/tc_relative_links.rb
mechanize-0.7.0 test/tc_relative_links.rb
mechanize-0.7.2 test/tc_relative_links.rb
mechanize-0.7.4 test/tc_relative_links.rb
mechanize-0.7.5 test/tc_relative_links.rb
mechanize-0.7.6 test/tc_relative_links.rb
mechanize-0.7.7 test/test_relative_links.rb
mechanize-0.7.8 test/test_relative_links.rb