Sha256: 76fbaf1fd2df0c9add9955a69bcbfeacb340952f433041c0afde7a949d4e3219

Contents?: true

Size: 1.64 KB

Versions: 3

Compression:

Stored size: 1.64 KB

Contents

require 'spec_helper'

describe Trackerific do
  include Trackerific
  
  describe :services do
    subject { Trackerific.services }
    it("should be an Array of Symbols") { should each { |m| m.should be_a Symbol } }
  end
  
  describe :service_get do
    
    context "with a valid service symbol" do
      subject { Trackerific.service_get(:fedex).superclass }
      it("should be a descendant of Trackerific::Service "){ should be Trackerific::Service }
    end
    
    context "with an invalid service symbol" do
      subject { Trackerific.service_get :ksjdfklsjdf }
      it { should be_nil }
    end
    
  end
  
  describe :tracking_service do
    
    context "when given a UPS tracking number" do
      subject { tracking_service "1Z12345E0291980793" }
      it { should be Trackerific::UPS}
    end
    
    context "when given a USPS tracking number" do
      subject { tracking_service "EJ958083578US" }
      it { should be Trackerific::USPS }
    end
    
    context "when given a FedEx tracking number" do
      subject { tracking_service "183689015000001" }
      it { should be Trackerific::FedEx }
    end
    
    context "when given an invalid tracking number" do
      subject { tracking_service "invalid tracking number" }
      it { should be_nil }
    end
    
  end
  
  describe :track_package do
    
    context "with a valid package id" do
      before { @details = track_package "XXXXXXXXXX" }
      subject { @details }
      it { should be_kind_of Trackerific::Details }
    end
    
    context "with an invalid package id" do
      specify { lambda { track_package "XXXxxxxxxx" }.should raise_error(Trackerific::Error) }
    end
  end
  
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
trackerific-0.6.2 spec/lib/trackerific_spec.rb
trackerific-0.6.1 spec/lib/trackerific_spec.rb
trackerific-0.6.0 spec/lib/trackerific_spec.rb