Sha256: 1bf39145c148eabe84c092996132fe72ffa4c6008382dce89aac46b1d019f963

Contents?: true

Size: 1.2 KB

Versions: 2

Compression:

Stored size: 1.2 KB

Contents

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


require File.dirname(__FILE__) + '/base.rb'


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

2 entries across 2 versions & 1 rubygems

Version Path
rufus-verbs-1.0.1 test/iconditional_test.rb
rufus-verbs-1.0.0 test/iconditional_test.rb