Sha256: 9092500d9cb69dd871c9620a1ccf253d31056158a34be5c43dfd1e788e8af4e7

Contents?: true

Size: 1.45 KB

Versions: 4

Compression:

Stored size: 1.45 KB

Contents

require 'spec_helper'

module Fedex
  describe TrackingInformation do
    let(:fedex) { Shipment.new(fedex_credentials) }

    context "shipments with tracking number", :vcr, :focus do
      let(:options) do
        { :package_id             => "123456789012",
          :package_type           => "TRACKING_NUMBER_OR_DOORTAG",
          :include_detailed_scans => true
        }
      end

      let(:uuid) { fedex.track(options).first.unique_tracking_number }

      it "returns an array of tracking information results" do
        results = fedex.track(options)
        results.should_not be_empty
      end

      it "returns events with tracking information" do
        tracking_info = fedex.track(options.merge(:uuid => uuid)).first

        tracking_info.events.should_not be_empty
      end

      it "fails if using an invalid package type" do
        fail_options = options

        fail_options[:package_type] = "UNKNOWN_PACKAGE"

        lambda { fedex.track(options) }.should raise_error
      end

      it "allows short hand tracking number queries" do
        shorthand_options = { :tracking_number => options[:package_id] }

        tracking_info = fedex.track(shorthand_options).first

        tracking_info.tracking_number.should == options[:package_id]
      end

      it "reports the status of the package" do
        tracking_info = fedex.track(options.merge(:uuid => uuid)).first

        tracking_info.status.should_not be_nil
      end

    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
fedex-3.6.1 spec/lib/fedex/track_spec.rb
fedex-3.6.0 spec/lib/fedex/track_spec.rb
fedex-3.4.0 spec/lib/fedex/track_spec.rb
fedex-3.3.1 spec/lib/fedex/track_spec.rb