Sha256: 8bea2b5d54306833ac1c05b980cee97996047f53b2e00891167d37c376458d5b

Contents?: true

Size: 1.01 KB

Versions: 8

Compression:

Stored size: 1.01 KB

Contents

#
# testing rufus-jig
#
# Sat Oct 31 23:27:02 JST 2009
#

require File.join(File.dirname(__FILE__), 'base')


class UtHttpPostTest < Test::Unit::TestCase

  def setup
    @h = Rufus::Jig::Http.new('127.0.0.1', 4567)
    @h.delete('/documents')
  end
  def teardown
    @h.close
  end

  def test_post

    b = @h.post(
      '/documents', '{"msg":"hello"}', :content_type => 'application/json')

    r = @h.last_response

    l = r.headers['Location']

    assert_equal 'created.', b
    assert_equal 201, r.status
    assert_not_nil l

    assert_equal({ 'msg' => 'hello' }, @h.get(l))
  end

  def test_post_and_decode_body

    b = @h.post(
      '/documents?mirror=true', '{"msg":"hello world"}', :content_type => :json)

    assert_equal({ 'msg' => 'hello world' }, b)

    assert_equal 0, @h.cache.size
  end

  def test_post_and_cache

    b = @h.post(
      '/documents?etag=true', '{"msg":"hello world"}', :content_type => :json)

    assert_equal({ 'msg' => 'hello world' }, b)

    assert_equal 1, @h.cache.size
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
rufus-jig-0.1.13 test/ut_1_http_post.rb
rufus-jig-0.1.12 test/ut_1_http_post.rb
rufus-jig-0.1.11 test/ut_1_http_post.rb
rufus-jig-0.1.10 test/ut_1_http_post.rb
rufus-jig-0.1.9 test/ut_1_http_post.rb
rufus-jig-0.1.8 test/ut_1_http_post.rb
rufus-jig-0.1.7 test/ut_1_http_post.rb
rufus-jig-0.1.6 test/ut_1_http_post.rb