Sha256: 5a67d156ec5dc366aa9ee32ce9d1f2b793a2d6a4de2a985218c298daa73444ea
Contents?: true
Size: 1.88 KB
Versions: 17
Compression:
Stored size: 1.88 KB
Contents
require File.expand_path('../../test_helper', __FILE__) module Stripe class ChargeRefundTest < Test::Unit::TestCase should "refunds should be listable" do @mock.expects(:get).once.returns(make_response(make_charge)) charge = Stripe::Charge.retrieve('test_charge') assert charge.refunds.first.kind_of?(Stripe::Refund) end should "refunds should be refreshable" do @mock.expects(:get).twice.returns(make_response(make_charge), make_response(make_refund(:id => 'refreshed_refund'))) charge = Stripe::Charge.retrieve('test_charge') refund = charge.refunds.first refund.refresh assert_equal 'refreshed_refund', refund.id end should "refunds should be updateable" do @mock.expects(:get). with("#{Stripe.api_base}/v1/charges/test_charge", nil, nil). once.returns(make_response(make_charge)) @mock.expects(:post). with("#{Stripe.api_base}/v1/refunds/ref_test_refund", nil, 'metadata[key]=value'). once.returns(make_response(make_refund(:metadata => {'key' => 'value'}))) charge = Stripe::Charge.retrieve('test_charge') refund = charge.refunds.first assert_equal nil, refund.metadata['key'] refund.metadata['key'] = 'value' refund.save assert_equal 'value', refund.metadata['key'] end should "create should return a new refund" do @mock.expects(:get). with("#{Stripe.api_base}/v1/charges/test_charge", nil, nil). once.returns(make_response(make_charge(:id => 'test_charge'))) @mock.expects(:post). with("#{Stripe.api_base}/v1/charges/test_charge/refunds", nil, 'amount=20'). once.returns(make_response(make_refund(:id => 'test_new_refund'))) charge = Stripe::Charge.retrieve('test_charge') refund = charge.refunds.create(:amount => 20) assert_equal 'test_new_refund', refund.id end end end
Version data entries
17 entries across 17 versions & 1 rubygems