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)
Mon Mar 23 17:33:50 -0700 2009
commit  3159e3a12c41e0aafbba7d4f1a3f7e1f604186cc
tree    8788b7a11698f6cc8f137d10e5dc13081fa66345
parent  2227f78519a2e862403baaa17c1592bdccfd0912
rufus-verbs / test / conditional_test.rb
100644 48 lines (33 sloc) 0.999 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
#
# Testing rufus-verbs
#
# jmettraux@gmail.com
#
# Wed Jan 16 13:54:36 JST 2008
#
 
 
require File.dirname(__FILE__) + '/base.rb'
 
 
class ConditionalTest < Test::Unit::TestCase
  include TestBaseMixin
 
  include Rufus::Verbs
 
 
  def test_1
 
    ep = ConditionalEndPoint.new(:host => "localhost", :port => 7777)
    expect 200, {}, ep.get(:resource => "items")
 
    res = ep.put :resource => "items", :id => 0 do
      "blockdata"
    end
    assert_equal 404, res.code.to_i
 
    res = ep.post :resource => "items", :id => 0 do
      "blockdata"
    end
    assert_equal 201, res.code.to_i
    assert_equal "http://localhost:7777/items/0", res['Location']
 
    res = expect 200, { 0 => "blockdata" }, ep.get(:res => "items")
    assert_kind_of Net::HTTPResponse, res
    assert_respond_to res, :lastmod
    i = res.object_id
    #p res.to_hash
 
    res = expect 200, { 0 => "blockdata" }, ep.get(:res => "items")
    assert_equal i, res.object_id
 
    assert_equal 1, ep.cache_current_size
  end
end