test/razorpay/test_payment.rb in razorpay-2.2.0 vs test/razorpay/test_payment.rb in razorpay-2.3.0

- old
+ new

@@ -5,11 +5,11 @@ class RazorpayPaymentTest < Minitest::Test def setup @payment_id = 'fake_payment_id' # Any request that ends with payments/payment_id - stub_get(%r{payments\/#{Regexp.quote(@payment_id)}$}, 'fake_payment') + stub_get(%r{payments\/#{@payment_id}$}, 'fake_payment') stub_get(/payments$/, 'payment_collection') end def test_payment_should_be_defined refute_nil Razorpay::Payment @@ -41,10 +41,18 @@ refund = Razorpay::Payment.fetch(@payment_id).refund assert_instance_of Razorpay::Refund, refund assert_equal refund.payment_id, @payment_id end + def test_payment_refund! + payment = Razorpay::Payment.fetch(@payment_id) + stub_get(%r{payments/#{@payment_id}$}, 'fake_refunded_payment') + stub_post(%r{payments/#{@payment_id}/refund$}, 'fake_refund', {}) + payment.refund! + assert_equal 'refunded', payment.status + end + def test_partial_refund # For some reason, stub doesn't work if I pass it a hash of post body stub_post(%r{payments/#{@payment_id}/refund$}, 'fake_refund', 'amount=2000') refund = Razorpay::Payment.fetch(@payment_id).refund(amount: 2000) assert_instance_of Razorpay::Refund, refund @@ -54,9 +62,16 @@ def test_payment_capture stub_post(%r{payments/#{@payment_id}/capture$}, 'fake_captured_payment', 'amount=5100') payment = Razorpay::Payment.fetch(@payment_id) payment = payment.capture(amount: 5100) + assert_equal 'captured', payment.status + end + + def test_payment_capture! + stub_post(%r{payments/#{@payment_id}/capture$}, 'fake_captured_payment', 'amount=5100') + payment = Razorpay::Payment.fetch(@payment_id) + payment.capture!(amount: 5100) assert_equal 'captured', payment.status end def test_payment_capture_without_fetch stub_post(%r{payments/#{@payment_id}/capture$}, 'fake_captured_payment', 'amount=5100')