File: tc_referer.rb

package info (click to toggle)
libwww-mechanize-ruby 0.7.6-2
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 752 kB
  • ctags: 607
  • sloc: ruby: 4,883; makefile: 4
file content (39 lines) | stat: -rw-r--r-- 1,216 bytes parent folder | download
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
require File.dirname(__FILE__) + "/helper"

class RefererTest < Test::Unit::TestCase
  def setup
    @agent = WWW::Mechanize.new
  end

  def test_no_referer
    page = @agent.get("http://localhost/referer")
    assert_equal('', page.body)
  end

  def test_send_referer
    page = @agent.get("http://localhost/tc_referer.html")
    page = @agent.click page.links.first
    assert_equal("http://localhost/tc_referer.html", page.body)
  end

  def test_fetch_two
    page1 = @agent.get("http://localhost/tc_referer.html")
    page2 = @agent.get("http://localhost/tc_pretty_print.html")
    page = @agent.click page1.links.first
    assert_equal("http://localhost/tc_referer.html", page.body)
  end

  def test_fetch_two_first
    page1 = @agent.get("http://localhost/tc_referer.html")
    page2 = @agent.get("http://localhost/tc_pretty_print.html")
    page = @agent.click page1.links
    assert_equal("http://localhost/tc_referer.html", page.body)
  end

  def test_post_form
    page1 = @agent.get("http://localhost/tc_referer.html")
    page2 = @agent.get("http://localhost/tc_pretty_print.html")
    page = @agent.submit page1.forms.first
    assert_equal("http://localhost/tc_referer.html", page.body)
  end
end