Sha256: 0e1c687c584d70812846a4f6c59e1e5df357a11f49f2b5b5c4234deaaec2b892

Contents?: true

Size: 1.21 KB

Versions: 3

Compression:

Stored size: 1.21 KB

Contents

require 'spec_helper'
require 'fakeweb'

FEDEX_TRACK_URL = "https://gateway.fedex.com/GatewayDC"

describe "Trackerific::FedEx" do
  include Fixtures
  
  before(:all) do
    @package_id = "183689015000001"
    @fedex = Trackerific::FedEx.new :account  => "123456789", :meter => "123456789"
  end
  
  describe "track_package" do
    context "with a successful response from the server" do
      before(:each) do
        FakeWeb.register_uri(
          :post,
          FEDEX_TRACK_URL,
          :body => load_fixture(:fedex_success_response)
        )
        @tracking = @fedex.track_package(@package_id)
      end
      specify { @tracking.should be_a Trackerific::Details }
      it "should have at least one event" do
        @tracking.events.length.should >= 1
      end
      it "should have a summary" do
        @tracking.summary.should_not be_empty
      end
    end
    context "with an error response from the server" do
      before(:all) do
        FakeWeb.register_uri(
          :post,
          FEDEX_TRACK_URL,
          :body => load_fixture(:fedex_error_response)
        )
      end
      specify { lambda { @fedex.track_package("invalid package id") }.should raise_error(Trackerific::Error) }
    end
  end
  
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
trackerific-0.3.2 spec/lib/fedex_spec.rb
trackerific-0.3.1 spec/lib/fedex_spec.rb
trackerific-0.3.0 spec/lib/fedex_spec.rb