Sha256: 6475b84c392c95e919ff9fea4ab7268034d4131daa56e027cb47ac2f05266604

Contents?: true

Size: 1.12 KB

Versions: 2

Compression:

Stored size: 1.12 KB

Contents

require "spec_helper"

describe Balanced::Hold, :vcr do
  before do
    api_key = Balanced::ApiKey.new.save
    Balanced.configure api_key.secret
    @marketplace = Balanced::Marketplace.new.save
    card = Balanced::Card.new(
      :card_number      => "5105105105105100",
      :expiration_month => "12",
      :expiration_year  => "2015"
    ).save
    @buyer = @marketplace.create_buyer(
        :email_address => 'buyer@example.org',
        :card_uri => card.uri
    )
  end

  describe "#void", :vcr do
    before do
      @hold = @buyer.hold :amount => 100
    end

    describe 'before', :vcr do
      subject { @hold.is_void }
      it { should be_false }
    end

    describe 'after', :vcr do
      before { @hold.void }

      subject { @hold.is_void }
      it { should be_true }
    end

    describe 'when exception is thrown', :vcr do
      before do
        @hold = @buyer.hold :amount => 150
        @debit = @hold.capture
      end

      it "should not change void state since its captured" do
        lambda { @hold.void }.should raise_error(Balanced::Conflict)
        @hold.is_void.should be_false
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
balanced-0.8.2 spec/balanced/resources/hold_spec.rb
balanced-0.8.1 spec/balanced/resources/hold_spec.rb