Sha256: b288b1bde961f76445a08ec23ba3579d3e2ea33aa14e154b5172a4e7edd59f32

Contents?: true

Size: 1.68 KB

Versions: 1

Compression:

Stored size: 1.68 KB

Contents

require 'spec_helper'

describe EasyPost::Report do
  TYPE = 'shipment'
  describe '#create' do
    it 'creates a report object' do
      report = EasyPost::Report.create(
                                       start_date: Date.today - 30,
                                       end_date: Date.today,
                                       type: TYPE
                                       )
      expect(report.object).to eq 'ShipmentReport'
      expect(['available', 'new']).to include(report.status)
    end
  end

  describe '#retrieve' do
    it 'retrieves a user created report by public_id' do
      report_1 = EasyPost::Report.create(
                                         start_date: Date.today - 30,
                                         end_date: Date.today,
                                         type: TYPE
                                         )
      report_2 = EasyPost::Report.retrieve(type: TYPE, id: report_1.id)

      expect(report_2.id).to eq(report_1.id)
    end
  end

  describe '#all' do
    it 'retrieves all user created reports' do
      report_1 = EasyPost::Report.create(
                                         start_date: Date.today - 25,
                                         end_date: Date.today,
                                         type: TYPE
                                         )

      report_2 = EasyPost::Report.create(
                                         start_date: Date.today - 29,
                                         end_date: Date.today,
                                         type: TYPE
                                         )
      reports = EasyPost::Report.all(type: TYPE)

      expect(reports.count).to eq 2
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
easypost-2.7.0 spec/report_spec.rb