File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -172,4 +172,29 @@ def test_tone_with_custom_headers
172172 ) . tone ( tone_input : tone_text , content_type : "application/json" )
173173 assert_equal ( tone_response , service_response . body )
174174 end
175+
176+ def test_tone_with_application_json
177+ tone_response = JSON . parse ( File . read ( Dir . getwd + "/resources/tone-v3-expect1.json" ) )
178+ headers = {
179+ "Content-Type" => "application/json"
180+ }
181+ tone_text = { "text" => "This is the text to be analyzed" }
182+ stub_request ( :post , "https://gateway.watsonplatform.net/tone-analyzer/api/v3/tone?version=2017-09-21" )
183+ . with (
184+ body : tone_text ,
185+ headers : {
186+ "Accept" => "application/json" ,
187+ "Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=" ,
188+ "Content-Type" => "application/json" ,
189+ "Host" => "gateway.watsonplatform.net"
190+ }
191+ ) . to_return ( status : 200 , body : tone_response . to_json , headers : headers )
192+ service = WatsonAPIs ::ToneAnalyzerV3 . new (
193+ version : "2017-09-21" ,
194+ username : "username" ,
195+ password : "password"
196+ )
197+ service_response = service . tone ( tone_input : tone_text , content_type : "application/json" )
198+ assert_equal ( tone_response , service_response . body )
199+ end
175200end
You can’t perform that action at this time.
0 commit comments