Sha256: 78ebc9b816d09731acec3792dca12e7b43b20706f2e720f800c9e903b65e4534

Contents?: true

Size: 934 Bytes

Versions: 24

Compression:

Stored size: 934 Bytes

Contents

require File.expand_path(File.dirname(__FILE__) + '/spec_helper')

describe "Web" do
  it "should be able to parse url and generate hashes" do
    require "knj/php"
    require "knj/web"
    
    url = "first=test&#{Knj::Web.urlenc("second[trala][]")}=1&#{Knj::Web.urlenc("second[trala][]")}=2&#{Knj::Web.urlenc("second[trala][]")}=3"
    res = Knj::Web.parse_urlquery(url)
    
    raise "Couldnt parse 'first'-element." if res["first"] != "test"
    raise "'second' wasnt a hash or contained invalid amounr of elements." if !res["second"].is_a?(Hash) or res["second"].length != 1
    raise "'trala' in 'second' wasnt a hash or contained invalid amount of elements." if !res["second"]["trala"].is_a?(Hash) or res["second"]["trala"].length != 3
    raise "'trala' in 'second' didnt contain the right elements." if res["second"]["trala"]["0"] != "1" or res["second"]["trala"]["1"] != "2" or res["second"]["trala"]["2"] != "3"
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
knjrbfw-0.0.12 spec/web_spec.rb
knjrbfw-0.0.11 spec/web_spec.rb
knjrbfw-0.0.10 spec/web_spec.rb
knjrbfw-0.0.9 spec/web_spec.rb