public
Description: GET, POST, PUT, DELETE, with something around (ruby)
Homepage: http://rufus.rubyforge.org/rufus-verbs
Clone URL: git://github.com/jmettraux/rufus-verbs.git
jmettraux (author)
Wed Apr 30 22:28:53 -0700 2008
commit  53ef8e94ca9995bcef04dc69e15e2d3454fe901a
tree    c2e7927bef03c22db556839f406fc2a10fcf8749
parent  b49482e567581e899e976930e0915d88f837aa60
rufus-verbs / test / cookie1_test.rb
100644 61 lines (39 sloc) 1.322 kb
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#
# Testing rufus-verbs
#
# jmettraux@gmail.com
#
# Sun Jan 13 12:33:03 JST 2008
#
 
require 'test/unit'
require 'testbase'
 
require 'rufus/verbs'
 
 
class Cookie1Test < Test::Unit::TestCase
    include TestBaseMixin
 
    include Rufus::Verbs
 
 
    def test_0
 
        ep = EndPoint.new :cookies => true
        class << ep
            attr_reader :cookies
        end
 
        assert_equal 0, ep.cookies.size
 
        ep.get :uri => "http://localhost:7777/cookie"
        assert_equal 1, ep.cookies.size
 
        req = ep.get :uri => "http://localhost:7777/cookie", :dry_run => true
        assert_match /^tcookie=\d*$/, req['Cookie']
    end
 
    def test_1
 
        ep0 = EndPoint.new :cookies => true
        ep1 = EndPoint.new :cookies => true
 
        ep0.post("http://localhost:7777/cookie") { "smurf0" }
        ep1.post("http://localhost:7777/cookie") { "smurf1" }
 
        expect 200, [ 'smurf0' ], ep0.get("http://localhost:7777/cookie")
        expect 200, [ 'smurf1' ], ep1.get("http://localhost:7777/cookie")
    end
 
    def test_2
 
        ep = EndPoint.new :cookies => false # explicitely
 
        res0 = ep.post("http://localhost:7777/cookie") { "smurf0" }
        res1 = expect 200, [], ep.get("http://localhost:7777/cookie")
 
        assert_not_equal res0['Set-Cookie'], res1['Set-Cookie']
    end
end