Sha256: faa05adeddfa4224bcf99f49e447b05b4f1cb67c5b7d95d1c32ee7ea66b39459

Contents?: true

Size: 998 Bytes

Versions: 10

Compression:

Stored size: 998 Bytes

Contents

require 'spec/helper'

describe Hash do
  
  describe ".to_params" do
    it "should transform a basic hash into HTTP POST Params" do
      {:a => "alpha", :b => "beta"}.to_params.split("&").should include "a=alpha"
      {:a => "alpha", :b => "beta"}.to_params.split("&").should include "b=beta"
    end
    
    it "should transform a more complex hash into HTTP POST Params" do
      {:a => "a", :b => ["c", "d", "e"]}.to_params.split("&").should include "a=a"
      {:a => "a", :b => ["c", "d", "e"]}.to_params.split("&").should include "b[0]=c"
      {:a => "a", :b => ["c", "d", "e"]}.to_params.split("&").should include "b[1]=d"
      {:a => "a", :b => ["c", "d", "e"]}.to_params.split("&").should include "b[2]=e"
    end

    it "should transform a very complex hash into HTTP POST Params" do
      params = {:a => "a", :b => [{:c => "c", :d => "d"}, {:e => "e", :f => "f"}]}.to_params.split("&")
      params.should include "a=a"
      params.should include "b[0][d]=d"
    end
  end
end

Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
em-http-request-0.2.13 spec/hash_spec.rb
em-http-request-0.2.10 spec/hash_spec.rb
em-http-request-0.2.9 spec/hash_spec.rb
astro-em-http-request-0.2.10 spec/hash_spec.rb
astro-em-http-request-0.2.9 spec/hash_spec.rb
astro-em-http-request-0.2.8 spec/hash_spec.rb
astro-em-http-request-0.2.7 spec/hash_spec.rb
em-http-request-0.2.7 spec/hash_spec.rb
astro-em-http-request-0.2.6 spec/hash_spec.rb
em-http-request-0.2.6 spec/hash_spec.rb