spec/lib/trackerific_spec.rb in trackerific-0.6.2 vs spec/lib/trackerific_spec.rb in trackerific-0.7.0

- old
+ new

@@ -1,62 +1,24 @@ 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 } } + describe "#configuration" do + subject { Trackerific.configuration } + it { should eq Trackerific::Configuration.config } 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 } + + describe "#configure" do + it "should delegate to Trackerific::Configuration.configure" do + Trackerific.configure {|config| config.this = :value } + Trackerific.configuration.this.should eq :value 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} + + describe "#track" do + it "should return an Array of Trackerific::Details" do + results = Trackerific.track("TEST") + results.should be_a Array + results.count.should eq 2 + results.all? {|r| r.should be_a Trackerific::Details } 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