Sha256: 907c718e931c7dd90cb710b83d4c1fb8996465a8f8d005783ac51cc83340d045

Contents?: true

Size: 557 Bytes

Versions: 5

Compression:

Stored size: 557 Bytes

Contents

describe Hash do
  describe '#to_query' do
    it "converts a simple hash into a query string" do
      {a: 1, b: 2}.to_query.should == 'a=1&b=2'
    end

    it "converts nested hashes into queries correctly" do
      {a: 1, b: {c: {d: 4}}}.to_query.should == 'a=1&b%5Bc%5D%5Bd%5D=4'
    end

    it "handles array values correctly" do
      {a: [1,2,3,4]}.to_query.should == 'a%5B%5D=1&a%5B%5D=2&a%5B%5D=3&a%5B%5D=4'
    end

    it "escapes any URL sensitive characters in the values" do
      {a: '%= '}.to_query.should == 'a=%25=%20'
    end
  end
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
under-os-http-1.4.0 spec/core/hash_spec.rb
under-os-1.3.0 spec/lib/core/hash_spec.rb
under-os-1.2.1 spec/lib/core/hash_spec.rb
under-os-1.2.0 spec/lib/core/hash_spec.rb
under-os-1.1.0 spec/lib/core/hash_spec.rb