Sha256: 8c2040959ecbd638d149b02451ae5eae73875cd9eafc01356c4628ab530d490d

Contents?: true

Size: 1.88 KB

Versions: 21

Compression:

Stored size: 1.88 KB

Contents

require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")

describe Braintree::LocalPaymentCompleted do
  describe "self.new" do
    it "is protected" do
      expect do
        Braintree::LocalPaymentCompleted.new
      end.to raise_error(NoMethodError, /protected method .new/)
    end
  end

  describe "self._new" do
    it "initializes the object with the appropriate attributes set" do
      params = {
        payment_id: "a-payment-id",
        payer_id: "a-payer-id",
        payment_method_nonce: "a-nonce",
        transaction: {
          id: "a-transaction-id",
          amount: "31.00",
          order_id: "an-order-id",
          status: Braintree::Transaction::Status::Authorized,
        },
      }
      local_payment_completed = Braintree::LocalPaymentCompleted._new(params)

      local_payment_completed.payment_id.should eq("a-payment-id")
      local_payment_completed.payer_id.should eq("a-payer-id")
      local_payment_completed.payment_method_nonce.should eq("a-nonce")
      local_payment_completed.transaction.id.should eq("a-transaction-id")
      local_payment_completed.transaction.amount.should eq(31.0)
      local_payment_completed.transaction.order_id.should eq("an-order-id")
      local_payment_completed.transaction.status.should eq(Braintree::Transaction::Status::Authorized)
    end

    it "initializes the object with the appropriate attributes set if no transaction is provided" do
      params = {
        payment_id: "a-payment-id",
        payer_id: "a-payer-id",
        payment_method_nonce: "a-nonce",
      }
      local_payment_completed = Braintree::LocalPaymentCompleted._new(params)

      local_payment_completed.payment_id.should eq("a-payment-id")
      local_payment_completed.payer_id.should eq("a-payer-id")
      local_payment_completed.payment_method_nonce.should eq("a-nonce")
      local_payment_completed.transaction.should be_nil
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
braintree-2.104.1 spec/unit/braintree/local_payment_completed_spec.rb