Sha256: 4e326a06a5d2e3f98a4f04cdabef9a93d360a20f8b51b8fb4e0e36d6f75bcd54

Contents?: true

Size: 1.17 KB

Versions: 8

Compression:

Stored size: 1.17 KB

Contents

require 'spec_helper'

describe EasyPost::ScanForm do
  let(:shipment) do
    shipment = EasyPost::Shipment.create(
      to_address: ADDRESS[:canada],
      from_address: ADDRESS[:california],
      parcel: PARCEL[:dimensions],
      customs_info: CUSTOMS_INFO[:shirt]
    )

    shipment.buy(
      rate: shipment.lowest_rate("usps")
    )
  end

  describe '#create' do
    it 'purchases postage for an international shipment' do
      scan_form = EasyPost::ScanForm.create(shipments: [shipment])

      expect(scan_form.id).not_to be_nil
      expect(scan_form.tracking_codes.first).to eq(shipment.tracking_code)
    end
  end

  describe '#retrieve' do
    let(:scan_form) { EasyPost::ScanForm.create(shipments: [shipment]) }

    it 'retrieves the same scan_form' do
      scan_form2 = EasyPost::ScanForm.retrieve(scan_form.id)

      expect(scan_form2.id).to eq(scan_form.id)
    end
  end

  describe '#all' do
    let!(:scan_form) { EasyPost::ScanForm.create(shipments: [shipment]) }

    it 'indexes the scan_forms' do
      params = {page_size: 2}
      scan_forms = EasyPost::ScanForm.all(params)

      expect(scan_forms["scan_forms"].first.id).to eq(scan_form.id)
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

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