Sha256: 05a568a8e1925f5cc0aaaf0da3043921bf25f2839397d30c4c8acfd7db6f1186

Contents?: true

Size: 1.55 KB

Versions: 12

Compression:

Stored size: 1.55 KB

Contents

require "test/unit"
$:.unshift(File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib')))
require "camping"

class Test_Camping_class_methods < Test::Unit::TestCase
  def test_escape_from_the_doc
    assert_equal "I%27d+go+to+the+museum+straightway%21", Camping.escape("I'd go to the museum straightway!")
  end

  def test_utf8_escape
    assert_equal "%E6%97%A5%E6%9C%AC%E5%9B%BD", Camping.escape("\346\227\245\346\234\254\345\233\275")
  end

  def test_unescape_from_the_doc
    assert_equal "I'd go to the museum straightway!", Camping.un("I%27d+go+to+the+museum+straightway%21")
  end

  def test_utf8_unescape
    assert_equal "\346\227\245\346\234\254\345\233\275", Camping.un("%E6%97%A5%E6%9C%AC%E5%9B%BD")
  end

  def test_qsp_from_the_doc
    input = Camping.qsp("name=Philarp+Tremain&hair=sandy+blonde")
    assert_equal "Philarp Tremain", input.name
    assert_equal "sandy blonde", input.hair
  end

  def test_qsp_with_array
    input = Camping.qsp("users[]=why&users[]=rambo")
    assert_equal ["why", "rambo"], input.users
  end

  def test_qsp_with_hash
    input = Camping.qsp("post[id]=1&post[user]=_why")
    hash = {'post' => {'id' => '1', 'user' => '_why'}}
    assert_equal hash, input
  end

  def test_qsp_malformed1
    input = Camping.qsp("name=Philarp+Tremain&&hair=sandy+blonde")
    assert_equal "Philarp Tremain", input.name
    assert_equal "sandy blonde", input.hair
  end

  def test_qsp_malformed2
    input = Camping.qsp("morta==del")
    assert_equal "=del", input.morta
  end

  # TODO : Test Camping.kp
  # TODO : Test Camping.run

end

Version data entries

12 entries across 12 versions & 3 rubygems

Version Path
bmarzolf-picnic-0.8.0.20090420 vendor/camping-2.0.20090420/test/test_camping.rb
bmarzolf-picnic-0.8.0.20090421 vendor/camping-2.0.20090421/test/test_camping.rb
bmarzolf-picnic-0.8.1.20090420 vendor/camping-2.0.20090420/test/test_camping.rb
zuk-picnic-0.7.999.20090212 vendor/camping-2.0.20090212/test/test_camping.rb
zuk-picnic-0.8.0.20090318 vendor/camping-2.0.20090212/test/test_camping.rb
zuk-picnic-0.8.0.20090427 vendor/camping-2.0.20090421/test/test_camping.rb
zuk-picnic-0.8.0.20090430 vendor/zuk-camping-2.0.20090429/test/test_camping.rb
zuk-picnic-0.8.1.20090501 vendor/zuk-camping-2.0.20090429/test/test_camping.rb
picnic-0.8.1.20100201 vendor/zuk-camping-2.0.20090429/test/test_camping.rb
picnic-0.8.0 vendor/camping-2.0.20090212/test/test_camping.rb
picnic-0.8.1 vendor/zuk-camping-2.0.20090429/test/test_camping.rb
picnic-0.8.1.1 vendor/zuk-camping-2.0.20090429/test/test_camping.rb