From 374c702fd893bbd46ae210ba2cf2bd4f6c6bf09a Mon Sep 17 00:00:00 2001 From: ankitdas13 Date: Fri, 24 May 2024 10:29:32 +0530 Subject: [PATCH] added failure case & doc correction --- documents/documents.md | 14 +++++++------- test/fixtures/document_error.json | 10 ++++++++++ test/razorpay/test_document.rb | 11 +++++++++++ 3 files changed, 28 insertions(+), 7 deletions(-) create mode 100644 test/fixtures/document_error.json diff --git a/documents/documents.md b/documents/documents.md index 6cbe9d5..48a0d68 100644 --- a/documents/documents.md +++ b/documents/documents.md @@ -11,10 +11,10 @@ Razorpay::Document.create({ **Parameters:** -| Name | Type | Description | -|-------|-----------|--------------------------------------------------| -| file* | string | The URL generated once the business proof document is uploaded. | -| purpose | string | Possible value is `dispute_evidence` | +| Name | Type | Description | +|---------|-----------|-----------------------------------------------------------------| +| file* | string | The URL generated once the business proof document is uploaded. | +| purpose | string | Possible value is `dispute_evidence` | **Response:** ```json @@ -40,9 +40,9 @@ Razorpay::Document.fetch(documentId) **Parameters:** -| Name | Type | Description | -|-------|-----------|--------------------------------------------------| -| documentId | string | The unique identifier of the document. | +| Name | Type | Description | +|-------------|-----------|--------------------------------------------------| +| documentId | string | The unique identifier of the document. | **Response:** ```json diff --git a/test/fixtures/document_error.json b/test/fixtures/document_error.json new file mode 100644 index 0000000..db52bbd --- /dev/null +++ b/test/fixtures/document_error.json @@ -0,0 +1,10 @@ +{ + "error": { + "code": "BAD_REQUEST_ERROR", + "description": "Invalid file id provided or merchant is unauthorized to access the fileId(s) provided", + "source": "NA", + "step": "NA", + "reason": "NA", + "metadata": {} + } +} \ No newline at end of file diff --git a/test/razorpay/test_document.rb b/test/razorpay/test_document.rb index cd2d95c..b4ca39b 100644 --- a/test/razorpay/test_document.rb +++ b/test/razorpay/test_document.rb @@ -12,5 +12,16 @@ def setup def test_document_should_be_defined refute_nil Razorpay::Document end + + def test_document_should_be_defined_exception + para_attr = {} + stub_get(%r{documents/#{@document_id}$}, 'document_error') + assert_raises(Razorpay::Error) do + document = Razorpay::Document.fetch(@document_id) + if document.error + raise Razorpay::Error.new, document.error['code'] + end + end + end end end