Sha256: 9f270c5c499296937f7d32f416067942bf3a0ae8e5e0aea5cc2db9a5bfab42e2

Contents?: true

Size: 1.31 KB

Versions: 1

Compression:

Stored size: 1.31 KB

Contents

require "spec_helper"

include PayPal::Invoice

describe PayPal::Invoice::Invoice do
  describe "#create" do
    context "when successful" do
      use_vcr_cassette "invoice/create/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 }

      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/failure"#, :record => :all

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

      subject { invoice.create }

      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_spec.rb