test/simple_test.rb in rufus-verbs-0.10 vs test/simple_test.rb in rufus-verbs-1.0.0
- old
+ new
@@ -5,123 +5,118 @@
# jmettraux@gmail.com
#
# Sun Jan 13 12:33:03 JST 2008
#
-require 'rubygems'
+require File.dirname(__FILE__) + '/base.rb'
-require 'test/unit'
-require 'testbase'
-require 'rufus/verbs'
-
-
class SimpleTest < Test::Unit::TestCase
- include TestBaseMixin
+ include TestBaseMixin
- include Rufus::Verbs
+ include Rufus::Verbs
- def test_0
+ def test_0
- #res = get :uri => "http://localhost:7777/items"
- #assert_equal 200, res.code.to_i
- #assert_equal "{}", res.body.strip
- expect 200, {}, get(:uri => "http://localhost:7777/items")
+ #res = get :uri => "http://localhost:7777/items"
+ #assert_equal 200, res.code.to_i
+ #assert_equal "{}", res.body.strip
+ expect 200, {}, get(:uri => "http://localhost:7777/items")
- res = post :uri => "http://localhost:7777/items/0", :d => "Toto"
- assert_equal 201, res.code.to_i
- assert_equal "http://localhost:7777/items/0", res['Location']
+ res = post :uri => "http://localhost:7777/items/0", :d => "Toto"
+ assert_equal 201, res.code.to_i
+ assert_equal "http://localhost:7777/items/0", res['Location']
- expect 200, { 0 => "Toto" }, get(:uri => "http://localhost:7777/items")
+ expect 200, { 0 => "Toto" }, get(:uri => "http://localhost:7777/items")
- res = get :host => "localhost", :port => 7777, :path => "/items"
- assert_equal 200, res.code.to_i
- assert_equal ({ 0 => "Toto" }), eval(res.body)
+ res = get :host => "localhost", :port => 7777, :path => "/items"
+ assert_equal 200, res.code.to_i
+ assert_equal ({ 0 => "Toto" }), eval(res.body)
- res = put :uri => "http://localhost:7777/items/0", :d => "Toto2"
- assert_equal 200, res.code.to_i
+ res = put :uri => "http://localhost:7777/items/0", :d => "Toto2"
+ assert_equal 200, res.code.to_i
- expect 200, { 0 => "Toto2" }, get(:uri => "http://localhost:7777/items")
+ expect 200, { 0 => "Toto2" }, get(:uri => "http://localhost:7777/items")
- res = put :uri => "http://localhost:7777/items/0", :d => "Toto3", :fake_put => true
- assert_equal 200, res.code.to_i
+ res = put :uri => "http://localhost:7777/items/0", :d => "Toto3", :fake_put => true
+ assert_equal 200, res.code.to_i
- expect 200, { 0 => "Toto3" }, get(:uri => "http://localhost:7777/items")
- end
+ expect 200, { 0 => "Toto3" }, get(:uri => "http://localhost:7777/items")
+ end
- def test_0b
+ def test_0b
- expect 200, {}, get(:uri => "http://localhost:7777/items")
+ expect 200, {}, get(:uri => "http://localhost:7777/items")
- res = post :uri => "http://localhost:7777/items", :d => "Toto"
- assert_equal 201, res.code.to_i
- assert_equal "http://localhost:7777/items/0", res['Location']
+ res = post :uri => "http://localhost:7777/items", :d => "Toto"
+ assert_equal 201, res.code.to_i
+ assert_equal "http://localhost:7777/items/0", res['Location']
- expect 200, "\"Toto\"", get(:uri => "http://localhost:7777/items/0")
+ expect 200, "\"Toto\"", get(:uri => "http://localhost:7777/items/0")
- res = post :uri => "http://localhost:7777/items", :d => "Smurf"
- assert_equal 201, res.code.to_i
- assert_equal "http://localhost:7777/items/1", res['Location']
+ res = post :uri => "http://localhost:7777/items", :d => "Smurf"
+ assert_equal 201, res.code.to_i
+ assert_equal "http://localhost:7777/items/1", res['Location']
- expect 200, "\"Smurf\"", get(:uri => "http://localhost:7777/items/1")
- end
+ expect 200, "\"Smurf\"", get(:uri => "http://localhost:7777/items/1")
+ end
- def test_1
+ def test_1
- ep = EndPoint.new(:host => "localhost", :port => 7777)
- expect 200, {}, ep.get(:resource => "items")
+ ep = EndPoint.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.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']
-
- expect 200, { 0 => "blockdata" }, ep.get(:res => "items")
+ 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']
- def test_2
+ expect 200, { 0 => "blockdata" }, ep.get(:res => "items")
+ end
- s = get(:uri => "http://localhost:7777/items", :body => true)
- assert_equal "{}", s.strip
- end
+ def test_2
- #
- # The "no-path" test
- #
- def test_3
+ s = get(:uri => "http://localhost:7777/items", :body => true)
+ assert_equal "{}", s.strip
+ end
- r = get "http://rufus.rubyforge.org"
- assert_kind_of Net::HTTPOK, r
- end
+ #
+ # The "no-path" test
+ #
+ def test_3
- #
- # HEAD
- #
- def test_4
+ r = get "http://rufus.rubyforge.org"
+ assert_kind_of Net::HTTPOK, r
+ end
- res = head "http://localhost:7777/items"
- assert_equal 200, res.code.to_i
- assert_nil res.body
- end
+ #
+ # HEAD
+ #
+ def test_4
- #
- # OPTIONS
- #
- def test_5
+ res = head "http://localhost:7777/items"
+ assert_equal 200, res.code.to_i
+ assert_nil res.body
+ end
- r = options "http://localhost:7777/items"
- assert_equal [ :delete, :get, :head, :options, :post, :put], r
- end
+ #
+ # OPTIONS
+ #
+ def test_5
- def test_6
+ r = options "http://localhost:7777/items"
+ assert_equal [ :delete, :get, :head, :options, :post, :put], r
+ end
- r = Rufus::Verbs::options "http://localhost:7777/items"
- assert_equal [ :delete, :get, :head, :options, :post, :put], r
- end
+ def test_6
+
+ r = Rufus::Verbs::options "http://localhost:7777/items"
+ assert_equal [ :delete, :get, :head, :options, :post, :put], r
+ end
end