added more json parser tests

git-svn-id: https://google-api-ruby-client.googlecode.com/svn/trunk@24 c1d61fac-ed7f-fcc1-18f7-ff78120a04ef
This commit is contained in:
mattpok@google.com 2010-08-24 19:22:53 +00:00
parent 1b232831c4
commit 003b046116
1 changed files with 9 additions and 0 deletions

View File

@ -25,6 +25,10 @@ describe Google::APIClient::JSONParser, 'generates json from hash' do
it 'should translate simple hash to JSON string' do
@parser.generate('test' => 23).should == "{\"test\":23}"
end
it 'should translate simple nested into to nested JSON string' do
@parser.generate({'test' => 23, 'test2' => {'foo' => 'baz', 12 => 3.14 }}).should ==
"{\"test2\":{\"12\":3.14,\"foo\":\"baz\"},\"test\":23}"
end
end
describe Google::APIClient::JSONParser, 'parses json string into hash' do
@ -35,5 +39,10 @@ describe Google::APIClient::JSONParser, 'parses json string into hash' do
it 'should parse simple json string into hash' do
@parser.parse('{"test":23}').should == {'test' => 23}
end
it 'should parse nested json object into hash' do
@parser.parse('{"test":23, "test2":{"bar":"baz", "foo":3.14}}').should ==
{'test' => 23, 'test2' => {'bar' => 'baz', 'foo' => 3.14}}
end
end