Sha256: 4df73deef4979b5a9bc42f7b774d07183b5bb8dc51fecfd547043c512a327e96

Contents?: true

Size: 1.7 KB

Versions: 7

Compression:

Stored size: 1.7 KB

Contents

require 'spec_helper'

describe EasyPost::Order do
  describe '#get_rates' do
    it 'refreshes rates' 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)

      rate_id = order.shipments.first.rates.first.id
      expect(rate_id).not_to be_nil

      order.get_rates

      new_rate_id = order.shipments.first.rates.first.id
      expect(new_rate_id).not_to be_nil
      expect(new_rate_id).not_to eq(rate_id)
    end
  end

  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
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
easypost-3.0.1 spec/order_spec.rb
easypost-3.0.0 spec/order_spec.rb
easypost-2.7.3 spec/order_spec.rb
easypost-2.7.2 spec/order_spec.rb
easypost-2.7.1 spec/order_spec.rb
easypost-2.7.0 spec/order_spec.rb
easypost-2.6.2 spec/order_spec.rb