Skip to content

Commit 01d2066

Browse files
committed
added spec for multipart request
1 parent 25d0cf9 commit 01d2066

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

test/imagekit/request_test.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,5 +65,18 @@
6565
expect(response).to_not have_key(:error)
6666
expect(response).to have_key(:response)
6767
end
68+
69+
it 'test_request_method_JSON_success_with_multipart_post' do
70+
stub_request(:post, 'https://www.exampleservererror/upload').to_return(status: 200, body: '{"id": "1"}', headers: {content_type: 'application/json'})
71+
response = @request_obj.request(:post, 'https://www.exampleservererror/upload', nil, { multipart: true })
72+
expect(response).to_not have_key(:error)
73+
expect(response).to have_key(:response)
74+
end
75+
76+
it 'test_request_method_non_JSON_fail_with_multipart_post' do
77+
stub_request(:post, 'https://www.exampleservererror/upload').to_return(status: 400, body: '{"message": "Server failed"}', headers: {content_type: 'application/json'})
78+
response = @request_obj.request(:post, 'https://www.exampleservererror/upload', nil, { multipart: true })
79+
expect(response).to have_key(:error)
80+
end
6881
end
6982
end

0 commit comments

Comments
 (0)