test/dryrun_test.rb in rufus-verbs-0.10 vs test/dryrun_test.rb in rufus-verbs-1.0.0
- old
+ new
@@ -5,66 +5,79 @@
# jmettraux@gmail.com
#
# Tue Jan 15 09:26:45 JST 2008
#
-require 'test/unit'
-require 'rufus/verbs'
+require File.dirname(__FILE__) + '/base.rb'
class DryRunTest < Test::Unit::TestCase
- include Rufus::Verbs
+ include Rufus::Verbs
- def test_0
+ def test_0
- req = put(
- :dry_run => true,
- :uri => "http://localhost:7777/items/1",
- :params => { "a" => "A", :b => :B })
+ req = put(
+ :dry_run => true,
+ :uri => "http://localhost:7777/items/1",
+ :params => { "a" => "A", :b => :B })
- assert_equal "/items/1?a=A&b=B", req.path
+ assert_equal "/items/1?a=A&b=B", req.path
- req = post(
- :dry_run => true,
- :uri => "http://localhost:7777/items/1",
- :params => { "a" => "A", :b => :B })
+ req = post(
+ :dry_run => true,
+ :uri => "http://localhost:7777/items/1",
+ :params => { "a" => "A", :b => :B })
- assert_equal "/items/1?a=A&b=B", req.path
+ assert_equal "/items/1?a=A&b=B", req.path
- req = put(
- :dry_run => true,
- :uri => "http://localhost:7777/items/1",
- :query => { "a" => "A", :b => :B })
+ req = put(
+ :dry_run => true,
+ :uri => "http://localhost:7777/items/1",
+ :query => { "a" => "A", :b => :B })
- assert_equal "/items/1?a=A&b=B", req.path
+ assert_equal "/items/1?a=A&b=B", req.path
- req = put(
- "http://localhost:7777/items/1?a=A", :d => "toto", :dry_run => true)
+ req = put(
+ "http://localhost:7777/items/1?a=A", :d => "toto", :dry_run => true)
- assert_equal "/items/1?a=A", req.path
- assert_equal "toto", req.body
- end
+ assert_equal "/items/1?a=A", req.path
+ assert_equal "toto", req.body
+ end
- def test_1
+ def test_1
- ep = Rufus::Verbs::EndPoint.new(
- :host => 'localhost',
- :resource => 'whatever')
+ ep = Rufus::Verbs::EndPoint.new(
+ :host => 'localhost',
+ :resource => 'whatever')
- req = ep.get(
- :dry_run => true,
- :resource => 'other',
- :params => { 'a' => 'A', 'b' => 'B' })
+ req = ep.get(
+ :dry_run => true,
+ :resource => 'other',
+ :params => { 'a' => 'A', 'b' => 'B' })
- assert_equal "/other?a=A&b=B", req.path
+ assert_equal "/other?a=A&b=B", req.path
- req = ep.post(
- :dry_run => true,
- :resource => 'other',
- :query => { 'a' => 'A', 'b' => 'B' })
-
- assert_equal "/other?a=A&b=B", req.path
- end
+ req = ep.post(
+ :dry_run => true,
+ :resource => 'other',
+ :query => { 'a' => 'A', 'b' => 'B' })
+
+ assert_equal "/other?a=A&b=B", req.path
+ end
+
+ def test_cgi_escape
+
+ ep = Rufus::Verbs::EndPoint.new(
+ :host => 'localhost',
+ :resource => 'whatever')
+
+ req = ep.post(
+ :dry_run => true,
+ :resource => 'other',
+ :query => { 'a' => 'A&A', 'b' => 'B?B' })
+
+ assert_equal "/other?a=A%26A&b=B%3FB", req.path
+ end
end