Sha256: 033aecccfe1478ee184d3f788bc8b42988487feb3be729b99acbe8304d0b76a4

Contents?: true

Size: 1.35 KB

Versions: 10

Compression:

Stored size: 1.35 KB

Contents

#
# Testing rufus-verbs
#
# jmettraux@gmail.com
#
# Sun Jan 13 12:33:03 JST 2008
#

require 'test/unit'
require 'testbase'

require 'rufus/verbs'


class ItemConditionalTest < Test::Unit::TestCase
    include TestBaseMixin

    include Rufus::Verbs


    def test_0

        require 'open-uri'
        f = open "http://localhost:7777/items"
        d = f.read
        f.close

        assert_equal "{}", d.strip
    end

    def test_1

        res = get :uri => "http://localhost:7777/items"

        assert_equal 200, res.code.to_i
        assert_equal "{}", res.body.strip

        p res['Etag']
        #p res['Last-Modified']
        assert res['Etag'].length > 0
        assert res['Last-Modified'].length > 0
    end

    def test_2

        res = get "http://localhost:7777/items"
        assert_equal 200, res.code.to_i

        lm = res['Last-Modified']
        etag = res['Etag']

        res = get(
            "http://localhost:7777/items", 
            :headers => { 'If-Modified-Since' => lm })
        assert_equal 304, res.code.to_i

        res = get(
            "http://localhost:7777/items", :h => { 'If-None-Match' => etag })
        assert_equal 304, res.code.to_i

        res = get(
            "http://localhost:7777/items", 
            :h => { 'If-Modified-Since' => lm, 'If-None-Match' => etag })
        assert_equal 304, res.code.to_i
    end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
rufus-verbs-0.4 test/iconditional_test.rb
rufus-verbs-0.1 test/iconditional_test.rb
rufus-verbs-0.7 test/iconditional_test.rb
rufus-verbs-0.5 test/iconditional_test.rb
rufus-verbs-0.6 test/iconditional_test.rb
rufus-verbs-0.8 test/iconditional_test.rb
rufus-verbs-0.10 test/iconditional_test.rb
rufus-verbs-0.2 test/iconditional_test.rb
rufus-verbs-0.3 test/iconditional_test.rb
rufus-verbs-0.9 test/iconditional_test.rb