spec/grpc_rest_spec.rb in grpc-rest-0.1.10 vs spec/grpc_rest_spec.rb in grpc-rest-0.1.13

- old
+ new

@@ -26,12 +26,12 @@ describe 'using get' do it 'should be successful' do get "/test/blah/xyz?test_id=abc" expect(response).to be_successful expect(response.parsed_body).to eq({ - 'some_int' => 1, - 'full_response' => %({"testId":"abc","foobar":"xyz"}) + 'someInt' => 1, + 'fullResponse' => %({"testId":"abc","foobar":"xyz"}) }) end end describe 'using body parameter' do @@ -42,32 +42,33 @@ } post '/test2?test_id=abc&foobar=xyz&timestamp_field=2024-04-03+01:02:03+UTC', params: params, as: :json expect(response).to be_successful expect(response.parsed_body).to eq({ - 'some_int' => 2, - 'full_response' => %({"testId":"abc","foobar":"xyz","secondRecord":{"subId":"id1","anotherId":"id2"},"timestampField":"2024-04-03T01:02:03Z"}) + 'someInt' => 2, + 'fullResponse' => %({"testId":"abc","foobar":"xyz","secondRecord":{"subId":"id1","anotherId":"id2"},"timestampField":"2024-04-03T01:02:03Z"}) }) end end describe 'using sub-record splat' do it 'should be successful' do post '/test3/xyz?test_id=abc' expect(response).to be_successful expect(response.parsed_body).to eq({ - 'some_int' => 3, - 'full_response' => %({"testId":"abc","subRecord":{"subId":"xyz"}}) + 'someInt' => 3, + 'fullResponse' => %({"testId":"abc","subRecord":{"subId":"xyz"}}) }) end end describe 'full body splat' do it 'should be successful' do params = { test_id: 'abc', + some_int: "65", foobar: 'xyz', repeated_string: ['W', 'T', 'F'], sub_record: { sub_id: 'id1', another_id: 'id2' @@ -92,12 +93,12 @@ timestamp_field: '2024-04-03 01:02:03 UTC', } post '/test4', params: params, as: :json expect(response).to be_successful expect(response.parsed_body).to eq({ - 'some_int' => 4, - 'full_response' => %({"testId":"abc","foobar":"xyz","repeatedString":["W","T","F"],"subRecord":{"subId":"id1","anotherId":"id2"},"secondRecord":{"subId":"id3","anotherId":"id4"},"structField":{"bool_key":true,"str_key":"val","nil_key":null,"list_key":[{"inner_key":"inner_val"}],"int_key":123},"timestampField":"2024-04-03T01:02:03Z","listValue":["F","Y","I"],"bareValue":45}) + 'someInt' => 4, + 'fullResponse' => %({"testId":"abc","foobar":"xyz","repeatedString":["W","T","F"],"subRecord":{"subId":"id1","anotherId":"id2"},"secondRecord":{"subId":"id3","anotherId":"id4"},"structField":{"bool_key":true,"str_key":"val","nil_key":null,"list_key":[{"inner_key":"inner_val"}],"int_key":123},"timestampField":"2024-04-03T01:02:03Z","listValue":["F","Y","I"],"bareValue":45,\"someInt\":65}) }) end end describe 'numeric timestamp' do @@ -106,12 +107,29 @@ timestamp_field: 1712692452 } post "/test4", params: params, as: :json expect(response).to be_successful expect(response.parsed_body).to eq({ - 'some_int' => 4, - 'full_response' => %({"timestampField":"2024-04-09T19:54:12Z"}) + 'someInt' => 4, + 'fullResponse' => %({"timestampField":"2024-04-09T19:54:12Z"}) }) end end + describe 'array of sub-records' do + it 'should be successful' do + params = { + sub_records: [{ + sub_id: 'id1', + another_id: 'id2' + }] + } + + post '/test4', params:, as: :json + expect(response).to be_successful + expect(response.parsed_body).to eq({ + 'someInt' => 4, + 'fullResponse' => %({"subRecords":[{"subId":"id1","anotherId":"id2"}]}) + }) + end + end end