Sha256: 707f387b67c4e161fa5ab99306edc6e456e571f0aadf6890d5cda3e6acba7879

Contents?: true

Size: 1.66 KB

Versions: 1

Compression:

Stored size: 1.66 KB

Contents

require 'spec_helper'

describe EasyPost::Order do
  describe '#create' do
    it 'creates an order out of a single shipment' do
      order = EasyPost::Order.create(
        to_address: ADDRESS[:california],
        from_address: ADDRESS[:missouri],
        shipments: [{
          parcel: {length: 8, width: 6, height: 4, weight: 12}
        }]
      )

      expect(order).to be_an_instance_of(EasyPost::Order)
      expect(order.shipments.first).to be_an_instance_of(EasyPost::Shipment)
    end

    it 'creates an order out of two shipments' do
      order = EasyPost::Order.create(
        to_address: ADDRESS[:california],
        from_address: ADDRESS[:missouri],
        carrier_accounts: [{id: "ca_12345678"}],
        shipments: [{
          parcel: {length: 8, width: 6, height: 4, weight: 12}
        },{
          parcel: {length: 8, width: 6, height: 4, weight: 12}
        }]
      )

      expect(order).to be_an_instance_of(EasyPost::Order)
      expect(order.shipments.first).to be_an_instance_of(EasyPost::Shipment)
    end

    it 'creates and buys an order using magic' do
      order = EasyPost::Order.create(
        to_address: ADDRESS[:canada],
        customs_info: CUSTOMS_INFO[:merchandise],
        containers: "*",
        items: [{sku: "V4C3D5R2Z6", value: 89.65}],
        #items: ["item_12345678"],
        # auto_pack: false,
        # auto_buy: false
      )

      order.pack
      order.buy(max_delivery_days: 2)
      # order.rates[0].buy
      # order.fulfill if order.is_fulfillable # fulfilled by easypost

      expect(order).to be_an_instance_of(EasyPost::Order)
      expect(order.shipments.first).to be_an_instance_of(EasyPost::Shipment)
    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
easypost-2.1.4 spec/order_spec.rb