Sha256: 6a88126bbb0b4798984b444f8dc3e70740ee71a336e9eed664528d69a6115e84

Contents?: true

Size: 1.36 KB

Versions: 1

Compression:

Stored size: 1.36 KB

Contents

require "spec_helper"

include PayPal::Invoice

describe PayPal::Invoice::Invoice do
  describe "#create_and_send" do
    context "when successful" do
      use_vcr_cassette "invoice/create_and_send/success"#, :record => :all

      let(:invoice) {
        PayPal::Invoice::Invoice.new(
          :merchant_email => 'chardy_1345003248_per@gmail.com',
          :payer_email => 'chardy_1345003165_per@gmail.com',
          :item_list => {
            :item => [
              {
                :name => 'iPhone 5',
                :quantity => 1,
                :unit_price => 1000.0
              }
            ]
          },
          :currency_code => 'USD',
          :payment_terms => 'Net30'
        )
      }

      subject { invoice.create_and_send }

      before { subject }

      it "sets the invoice_id" do
        invoice.invoice_id.should_not be_nil
      end

      its(:success?) { should be_true }
      its(:valid?) { should be_true }
    end

    context "when failure" do
      use_vcr_cassette "invoice/create_and_send/failure"#, :record => :all

      let(:invoice) {
        PayPal::Invoice::Invoice.new(
          :currency_code => 'USD'
        )
      }

      subject { invoice.create_and_send }

      before { subject }

      its(:success?) { should be_false }
      its(:valid?) { should be_false }
      its(:errors) { should_not be_empty }
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
paypal-payment-0.1.2 spec/paypal/invoice/create_and_send_spec.rb