public
Description: URITemplate is a parser for URI Templates as defined in the URI Template specification (http://bitworking.org/projects/URI-Templates).
Homepage: http://uri-templates.rubyforge.org/
Clone URL: git://github.com/juretta/uri-templates.git
Stefan Saasen (author)
Mon Mar 17 20:38:56 -0700 2008
uri-templates / test / test_uri_template.rb
100644 18 lines (14 sloc) 0.583 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# Created by Stefan Saasen.
# Copyright (c) 2008. All rights reserved.
require File.dirname(__FILE__) + '/test_helper.rb'
 
class TestUriTemplate < Test::Unit::TestCase
  def test_encode
    assert_equal "stefan", UriTemplate::Encoder.encode("stefan")
    assert_equal '%26', UriTemplate::Encoder.encode("&")
  end
  
  def test_replace
    ut = UriTemplate::URI.new("http://example.org/{userid}")
    assert_equal "http://example.org/stefan", ut.replace("userid" => "stefan")
    assert_equal "http://example.org/paul%20auster", ut.replace("userid" => "paul auster")
  end
  
end