Sha256: 1fb8d571cb9ab529c48efd929953a9ca754ac47616733448875981df59864bb9

Contents?: true

Size: 999 Bytes

Versions: 8

Compression:

Stored size: 999 Bytes

Contents

require 'spec_helper'

describe CatarsePaypalExpress::ContributionActions do
  let(:contribution_actions) { CatarsePaypalExpress::ContributionActions.new(contribution) }
  let(:gateway) { double('gateway') }
  let(:contribution) {
    double(:contribution, {id: 1, payment_id: '123a'})
  }
  let(:refund_return) { double }

  before do
    CatarsePaypalExpress::Gateway.stub(:instance).and_return(gateway)
  end

  describe '#refund' do
    subject do
      contribution_actions.refund
    end

    before do
      contribution_actions.should_receive(:gateway).and_call_original
      gateway.should_receive(:refund).with(nil, contribution.payment_id).and_return(refund_return)
    end

    context "success refund" do
      before do
        refund_return.stub(:success?).and_return(true)
      end

      it { should be_true }
    end

    context "failed refund" do
      before do
        refund_return.stub(:success?).and_return(false)
      end

      it { should be_false }
    end
  end
end

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
catarse_paypal_express-2.2.4 spec/lib/catarse_paypal_express/contribution_actions_spec.rb
catarse_paypal_express-3.0.2 spec/lib/catarse_paypal_express/contribution_actions_spec.rb
funddit_paypal_express-3.0.1 spec/lib/catarse_paypal_express/contribution_actions_spec.rb
catarse_paypal_express-3.0.1 spec/lib/catarse_paypal_express/contribution_actions_spec.rb
catarse_paypal_express-3.0.0 spec/lib/catarse_paypal_express/contribution_actions_spec.rb
catarse_paypal_express-2.2.3 spec/lib/catarse_paypal_express/contribution_actions_spec.rb
catarse_paypal_express-2.2.2 spec/lib/catarse_paypal_express/contribution_actions_spec.rb
catarse_paypal_express-2.2.1 spec/lib/catarse_paypal_express/contribution_actions_spec.rb