Sha256: eec74a382e90112921f5167db48c1f499dcda17b044d4cc5d554ff67ea791f9e

Contents?: true

Size: 1.15 KB

Versions: 5

Compression:

Stored size: 1.15 KB

Contents

require "spec_helper"

describe Balanced::Hold do
  use_vcr_cassette
  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("buyer@example.org", card.uri)
  end

  describe "#void" do
    use_vcr_cassette

    before do
      @hold = @buyer.hold 100
    end

    describe 'before' do
      use_vcr_cassette
      subject { @hold.is_void }
      it { should be_false }
    end

    describe 'after' do
      use_vcr_cassette
      before { @hold.void }

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

    describe 'when exception is thrown' do
      use_vcr_cassette
      before do
        @hold = @buyer.hold 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
      # void here.


    end

  end
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
balanced-ach-0.1 spec/balanced/resources/hold_spec.rb
balanced-0.3.11 spec/balanced/resources/hold_spec.rb
balanced-0.3.10 spec/balanced/resources/hold_spec.rb
balanced-0.3.8 spec/balanced/resources/hold_spec.rb
balanced-0.3.7 spec/balanced/resources/hold_spec.rb