test/paid/util_test.rb in paid-0.1.0 vs test/paid/util_test.rb in paid-1.0.0

- old
+ new

@@ -1,10 +1,10 @@ require File.expand_path('../../test_helper', __FILE__) module Paid class UtilTest < Test::Unit::TestCase - should "symbolize_names should convert names to symbols" do + should "symbolize_keys should convert keys to symbols" do start = { 'foo' => 'bar', 'array' => [{ 'foo' => 'bar' }], 'nested' => { 1 => 2, @@ -20,40 +20,31 @@ :symbol => 9, :string => nil } } - symbolized = Paid::Util.symbolize_names(start) + symbolized = Paid::Util.symbolize_keys(start) assert_equal(finish, symbolized) end - should "parse a nil opts argument" do - api_key, headers = Paid::Util.parse_opts(nil) - assert_equal({}, headers) - assert_equal(nil, api_key) - end + should 'query_array should convert { :a => "value" } to []' do + start = { :a => "value" } + finish = ["a=value"] - should "parse a string opts argument" do - api_key, headers = Paid::Util.parse_opts('foo') - assert_equal({}, headers) - assert_equal('foo', api_key) + assert_equal(finish, Paid::Util.query_array(start)) end - should "parse a hash opts argument with just api_key" do - api_key, headers = Paid::Util.parse_opts({:api_key => 'foo'}) - assert_equal({}, headers) - assert_equal('foo', api_key) - end + should 'query_array should convert { :a => { :b => { :c => "cvalue" } } } to ["a[b][c]=cvalue"]' do + start = { :a => { :b => { :c => "cvalue" } } } + finish = ["a[b][c]=cvalue"] - should "parse a hash opts argument with just idempotency_key" do - api_key, headers = Paid::Util.parse_opts({:idempotency_key => 'foo'}) - assert_equal({:idempotency_key => 'foo'}, headers) - assert_equal(nil, api_key) + assert_equal(finish, Paid::Util.query_array(start)) end - should "parse a hash opts argument both idempotency_key and api_key" do - api_key, headers = Paid::Util.parse_opts({:api_key => 'bar', :idempotency_key => 'foo'}) - assert_equal({:idempotency_key => 'foo'}, headers) - assert_equal('bar', api_key) + should 'query_array should convert { :a => [1, 2] } to ["a[]=1", "a[]=2"]' do + start = { :a => [1, 2] } + finish = ["a[]=1", "a[]=2"] + + assert_equal(finish, Paid::Util.query_array(start)) end end end