Sha256: 423f60e2bf3294d8686e4ca51ec5b285c5fff9c934df08c0329d143dee9e2893

Contents?: true

Size: 1.49 KB

Versions: 4

Compression:

Stored size: 1.49 KB

Contents

require 'spec_helper'

# rspec spec/tophatter_merchant/order_spec.rb
describe TophatterMerchant::Order do
  describe '.all' do
    xit 'returns all orders' do
      orders = TophatterMerchant::Order.all(filter: 'unfulfilled')
      expect(orders.length).to be(2)
    end
  end

  describe '.retrieve' do
    xit 'retrieves an order' do
      order = TophatterMerchant::Order.retrieve(359887509)
      expect(order.order_id).to eq(359887509)
      expect(order.status).to eq('paid')
      expect(order.product_identifier).to eq('DEFAULT')
      expect(order.customer_id).to eq(981984628)
      expect(order.customer_name).to eq('Optimus Prime')
      expect(order.line_items.count).to eq(3)
      expect(order.address1).to eq('201 Valley Street')
      expect(order.city).to eq('Los Altos')
      expect(order.state).to eq('CA')
      expect(order.postal_code).to eq('94022')
      expect(order.country).to eq('USA')
    end
  end

  describe '.fulfill' do
    xit 'fulfills an order' do
      order = TophatterMerchant::Order.fulfill(359887509, carrier: 'USPS', tracking_number: 'CX263292019US')
      expect(order.status).to eq('shipped')
      expect(order.carrier).to eq('usps')
      expect(order.tracking_number).to eq('CX263292019US')
    end
  end

  describe '.refund' do
    xit 'refunds an order' do
      order = TophatterMerchant::Order.refund(359887509, type: 'partial', reason: 'delay_in_shipping', fees: ['shipping_fee'])
      expect(order.available_refunds).to eq('buyer_fee' => 399.0)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
tophatter-merchant-1.3.3 spec/tophatter_merchant/order_spec.rb
tophatter-merchant-1.3.2 spec/tophatter_merchant/order_spec.rb
tophatter-merchant-1.3.1 spec/tophatter_merchant/order_spec.rb
tophatter-merchant-1.3.0 spec/tophatter_merchant/order_spec.rb