Sha256: 85cf458a9fac9fa6e88c2754a9a00caabdc9a301c6bae953df5897503c28de38

Contents?: true

Size: 1.3 KB

Versions: 4

Compression:

Stored size: 1.3 KB

Contents

require 'spec_helper'

describe FakeBraintree::SinatraApp do
  context "Braintree::Transaction.sale" do
    it "successfully creates a transaction" do
      result = Braintree::Transaction.sale(:payment_method_token => cc_token, :amount => 10.00)
      result.should be_success
    end

    context "when all cards are declined" do
      before { FakeBraintree.decline_all_cards! }

      it "fails" do
        result = Braintree::Transaction.sale(:payment_method_token => cc_token, :amount => 10.00)
        result.should_not be_success
      end
    end
  end
end

describe FakeBraintree::SinatraApp do
  context "Braintree::Transaction.find" do
    it "can find a created sale" do
      id = create_transaction.id
      result = Braintree::Transaction.find(id)
      result.amount.should == amount
    end

    it "can find >1 transaction" do
      Braintree::Transaction.find(create_transaction.id).should be
      Braintree::Transaction.find(create_transaction.id).should be
    end

    it "raises an error when the transaction does not exist" do
      expect { Braintree::Transaction.find('foobar') }.to raise_error(Braintree::NotFoundError)
    end

    def create_transaction
      Braintree::Transaction.sale(:payment_method_token => cc_token, :amount => amount).transaction
    end

    let(:amount) { 10.00 }
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
fake_braintree-0.2.0 spec/fake_braintree/transaction_spec.rb
fake_braintree-0.1.1 spec/fake_braintree/transaction_spec.rb
fake_braintree-0.1.0 spec/fake_braintree/transaction_spec.rb
fake_braintree-0.0.6 spec/fake_braintree/transaction_spec.rb