Sha256: 33e690844e651dfe7418fba2880d26d8921a66fca8b8bd1f484735db7d7437f9
Contents?: true
Size: 1.32 KB
Versions: 1
Compression:
Stored size: 1.32 KB
Contents
require "test/unit" require "extensions/array" require "extensions/hash" require "extensions/string" class TestToAndFromUrl < Test::Unit::TestCase def test_simple_hash params = {:hello => 'joe', :fun => 'trips', :trip => 'Florida'} assert_equal("trip=Florida&hello=joe&fun=trips", CGI::unescape(params.to_url_params)) end def test_simple_hash_with_symbols_instead_of_strings params = {:hello => :joe, :fun => :trips, :trip => :Florida} assert_equal("trip=Florida&hello=joe&fun=trips", CGI::unescape(params.to_url_params)) end def test_only_hash_of_hashes params = {:hello => 'joe', :fun => {:stuff => {:basketball => :sports, :football => 'sports'}, :trip => 'Florida'}} assert_equal("hello=joe&fun[trip]=Florida&fun[stuff][football]=sports&fun[stuff][basketball]=sports", CGI::unescape(params.to_url_params)) end def test_hash_of_hashes_and_arrays params = {:hello => 'joe', :fun => {:stuff => {:sports => ['basketball', 'football']}, :trip => 'Florida'}} assert_equal("hello=joe&fun[trip]=Florida&fun[stuff][sports][]=basketball&fun[stuff][sports][]=football", CGI::unescape(params.to_url_params)) end def test_arrays_at_root params = {:sports => ['basketball', 'football']} assert_equal("sports[]=basketball&sports[]=football", CGI::unescape(params.to_url_params)) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
valdemaximus-xx-0.4.0 | test/tc_hash.rb |