Sha256: 755491f4c36be4c89116bf22131541e845c3c6b946008c2c22f12737c8ce402c

Contents?: true

Size: 1.69 KB

Versions: 7

Compression:

Stored size: 1.69 KB

Contents

require 'spec_helper'

# rspec spec/tophatter_merchant/order_spec.rb
describe TophatterMerchant::Order do
  describe '.schema', :vcr do
    it 'returns the schema' do
      schema = TophatterMerchant::Order.schema
      expect(schema.find { |component| component['field'] == 'order_id' }['name']).to eq('Order ID')
    end
  end

  describe '.all' do
    it 'returns all orders', :vcr do
      orders = TophatterMerchant::Order.all(filter: 'unfulfilled')
      expect(orders.length).to be(2)
    end
  end

  describe '.retrieve' do
    it 'retrieves an order', :vcr 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.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('United States')
    end
  end

  describe '.fulfill' do
    it 'fulfills an order', :vcr 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
    it 'refunds an order', :vcr 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

7 entries across 7 versions & 1 rubygems

Version Path
tophatter-merchant-1.2.1 spec/tophatter_merchant/order_spec.rb
tophatter-merchant-1.2.0 spec/tophatter_merchant/order_spec.rb
tophatter-merchant-1.1.9 spec/tophatter_merchant/order_spec.rb
tophatter-merchant-1.1.8 spec/tophatter_merchant/order_spec.rb
tophatter-merchant-1.1.7 spec/tophatter_merchant/order_spec.rb
tophatter-merchant-1.1.6 spec/tophatter_merchant/order_spec.rb
tophatter-merchant-1.1.5 spec/tophatter_merchant/order_spec.rb