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