Sha256: 8be95da51c746f9953054b52dc095f9329d0c318190924af6f1504fb929ee538

Contents?: true

Size: 1.25 KB

Versions: 7

Compression:

Stored size: 1.25 KB

Contents

require 'spec_helper'
describe Seko::Tracking do

  let(:dpd_url)      { 'http://www.dpd.co.uk/apps/tracking/?reference=:tracking_number&postcode=#results' }
  let(:ups_url)      { 'http://wwwapps.ups.com/WebTracking/track?trackNums=:tracking_number&track.x=Track' }
  let(:ups_number)   { '1Z87932WD945835927' }
  let(:dpd_number)   { '15503259038100Z' }
  let(:ups_tracking) { Seko::Tracking.new('', ups_number) }
  let(:dpd_tracking) { Seko::Tracking.new('', dpd_number) }

  describe '#get_carrier' do
    it 'returns the carrier based on a regular expression match' do
      expect(ups_tracking.get_carrier).to eq('UPS')
      expect(dpd_tracking.get_carrier).to eq('DPD')
    end
  end

  describe '#carrier_destination' do
    it 'returns the tracking url for the provided carrier' do
      expect(ups_tracking.carrier_destination).to eq(ups_url)
      expect(dpd_tracking.carrier_destination).to eq(dpd_url)
    end
  end

  describe '#url' do
    it 'returns the final tracking url' do
      ups_tracking_number = ups_url.gsub(':tracking_number', ups_number)
      dpd_tracking_number = dpd_url.gsub(':tracking_number', dpd_number)
      expect(ups_tracking.url).to eq(ups_tracking_number)
      expect(dpd_tracking.url).to eq(dpd_tracking_number)
    end
  end

end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
seko-0.0.10 spec/lib/tracking_spec.rb
seko-0.0.9 spec/lib/tracking_spec.rb
seko-0.0.8 spec/lib/tracking_spec.rb
seko-0.0.7 spec/lib/tracking_spec.rb
seko-0.0.6 spec/lib/tracking_spec.rb
seko-0.0.5 spec/lib/tracking_spec.rb
seko-0.0.4 spec/lib/tracking_spec.rb