usps 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +84 -0
- data/Rakefile +6 -8
- data/lib/usps.rb +6 -5
- data/lib/usps/address.rb +1 -1
- data/lib/usps/configuration.rb +1 -1
- data/lib/usps/request.rb +2 -1
- data/lib/usps/request/tracking_field_lookup.rb +28 -0
- data/lib/usps/response.rb +1 -0
- data/lib/usps/response/address_standardization.rb +15 -1
- data/lib/usps/response/city_and_state_lookup.rb +16 -2
- data/lib/usps/response/tracking_field_lookup.rb +34 -0
- data/lib/usps/response/tracking_lookup.rb +1 -1
- data/lib/usps/track_detail.rb +49 -0
- data/lib/usps/version.rb +1 -1
- data/spec/address_spec.rb +14 -14
- data/spec/configuration_spec.rb +4 -4
- data/spec/data/tracking_field_lookup.xml +41 -0
- data/spec/data/tracking_field_lookup_2.xml +17 -0
- data/spec/request/address_standardization_spec.rb +13 -13
- data/spec/request/base_spec.rb +2 -2
- data/spec/request/city_and_state_lookup_spec.rb +10 -10
- data/spec/request/delivery_confirmation_certify_spec.rb +3 -3
- data/spec/request/delivery_confirmation_spec.rb +27 -27
- data/spec/request/tracking_field_spec.rb +20 -0
- data/spec/request/tracking_spec.rb +5 -5
- data/spec/request/zip_code_lookup_spec.rb +11 -11
- data/spec/response/address_standardization_spec.rb +9 -9
- data/spec/response/city_and_state_lookup_spec.rb +6 -6
- data/spec/response/delivery_confirmation_spec.rb +19 -19
- data/spec/response/tracking_field_lookup_spec.rb +28 -0
- data/spec/response/tracking_lookup_spec.rb +10 -10
- data/spec/track_detail_spec.rb +51 -0
- data/spec/usps_spec.rb +1 -1
- metadata +66 -90
- data/README.rdoc +0 -60
- data/lib/usps/request/signature_confirmation.rb +0 -44
- data/spec/request/signature_confirmation_spec.rb +0 -0
- data/spec/response/signature_confirmation_spec.rb +0 -0
@@ -0,0 +1,17 @@
|
|
1
|
+
<?xml version="1.0"?>
|
2
|
+
<TrackResponse>
|
3
|
+
<TrackInfo ID="01805213907042762274">
|
4
|
+
<TrackSummary>
|
5
|
+
<EventTime></EventTime>
|
6
|
+
<EventDate></EventDate>
|
7
|
+
<Event>DELIVERED</Event>
|
8
|
+
<EventCity>NEWTON</EventCity>
|
9
|
+
<EventState>IA</EventState>
|
10
|
+
<EventZIPCode>50208</EventZIPCode>
|
11
|
+
<EventCountry/>
|
12
|
+
<FirmName></FirmName>
|
13
|
+
<Name></Name>
|
14
|
+
<AuthorizedAgent></AuthorizedAgent>
|
15
|
+
</TrackSummary>
|
16
|
+
</TrackInfo>
|
17
|
+
</TrackResponse>
|
@@ -3,16 +3,16 @@ require 'spec_helper'
|
|
3
3
|
describe USPS::Request::AddressStandardization do
|
4
4
|
it "should be using the proper USPS api settings" do
|
5
5
|
USPS::Request::AddressStandardization.tap do |klass|
|
6
|
-
klass.secure.
|
7
|
-
klass.api.
|
8
|
-
klass.tag.
|
6
|
+
expect(klass.secure).to be_falsey
|
7
|
+
expect(klass.api).to eq('Verify')
|
8
|
+
expect(klass.tag).to eq('AddressValidateRequest')
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
12
|
it "should not allow more than 5 addresses" do
|
13
|
-
|
13
|
+
expect do
|
14
14
|
USPS::Request::AddressStandardization.new([USPS::Address.new] * 6)
|
15
|
-
end.
|
15
|
+
end.to raise_exception(ArgumentError)
|
16
16
|
end
|
17
17
|
|
18
18
|
it "should be able to build a proper request" do
|
@@ -31,15 +31,15 @@ describe USPS::Request::AddressStandardization do
|
|
31
31
|
xml = Nokogiri::XML.parse(request.build)
|
32
32
|
|
33
33
|
xml.search('Address').first.tap do |node|
|
34
|
-
node.attr('ID').
|
34
|
+
expect(node.attr('ID')).to eq('0')
|
35
35
|
|
36
|
-
node.search('FirmName').text.
|
37
|
-
node.search('Address1').text.
|
38
|
-
node.search('Address2').text.
|
39
|
-
node.search('City').text.
|
40
|
-
node.search('State').text.
|
41
|
-
node.search('Zip5').text.
|
42
|
-
node.search('Zip4').text.
|
36
|
+
expect(node.search('FirmName').text).to eq('Widget Tel Co.')
|
37
|
+
expect(node.search('Address1').text).to eq('Suite 2000')
|
38
|
+
expect(node.search('Address2').text).to eq('999 Serious Business Av')
|
39
|
+
expect(node.search('City').text).to eq('Awesome Town')
|
40
|
+
expect(node.search('State').text).to eq('FL')
|
41
|
+
expect(node.search('Zip5').text).to eq('12345')
|
42
|
+
expect(node.search('Zip4').text).to eq('9900')
|
43
43
|
end
|
44
44
|
end
|
45
45
|
end
|
data/spec/request/base_spec.rb
CHANGED
@@ -10,7 +10,7 @@ describe USPS::Request::Base do
|
|
10
10
|
|
11
11
|
xml = Nokogiri::XML.parse(sub.build)
|
12
12
|
|
13
|
-
xml.root.name.
|
14
|
-
xml.root.attr('USERID').
|
13
|
+
expect(xml.root.name).to eq('TestingTag')
|
14
|
+
expect(xml.root.attr('USERID')).to eq(USPS.username)
|
15
15
|
end
|
16
16
|
end
|
@@ -3,16 +3,16 @@ require 'spec_helper'
|
|
3
3
|
describe USPS::Request::CityAndStateLookup do
|
4
4
|
it "should be using the proper USPS api settings" do
|
5
5
|
USPS::Request::CityAndStateLookup.tap do |klass|
|
6
|
-
klass.secure.
|
7
|
-
klass.api.
|
8
|
-
klass.tag.
|
6
|
+
expect(klass.secure).to be_falsey
|
7
|
+
expect(klass.api).to eq('CityStateLookup')
|
8
|
+
expect(klass.tag).to eq('CityStateLookupRequest')
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
12
|
it "should not allow more than 5 addresses" do
|
13
|
-
|
13
|
+
expect do
|
14
14
|
USPS::Request::CityAndStateLookup.new([12345] * 10)
|
15
|
-
end.
|
15
|
+
end.to raise_exception(ArgumentError)
|
16
16
|
end
|
17
17
|
|
18
18
|
it "should be able to build a proper request" do
|
@@ -23,10 +23,10 @@ describe USPS::Request::CityAndStateLookup do
|
|
23
23
|
xml = Nokogiri::XML.parse(request.build)
|
24
24
|
|
25
25
|
#
|
26
|
-
xml.search('ZipCode[@ID="0"]/Zip5').text.
|
27
|
-
xml.search('ZipCode[@ID="1"]/Zip5').text.
|
28
|
-
xml.search('ZipCode[@ID="2"]/Zip5').text.
|
29
|
-
xml.search('ZipCode[@ID="3"]/Zip5').text.
|
30
|
-
xml.search('ZipCode[@ID="4"]/Zip5').text.
|
26
|
+
expect(xml.search('ZipCode[@ID="0"]/Zip5').text).to eq('90210')
|
27
|
+
expect(xml.search('ZipCode[@ID="1"]/Zip5').text).to eq('48917')
|
28
|
+
expect(xml.search('ZipCode[@ID="2"]/Zip5').text).to eq('49423')
|
29
|
+
expect(xml.search('ZipCode[@ID="3"]/Zip5').text).to eq('99111')
|
30
|
+
expect(xml.search('ZipCode[@ID="4"]/Zip5').text).to eq('12345')
|
31
31
|
end
|
32
32
|
end
|
@@ -3,9 +3,9 @@ require 'spec_helper'
|
|
3
3
|
describe USPS::Request::DeliveryConfirmationCertify do
|
4
4
|
it 'should be using the proper USPS api settings' do
|
5
5
|
USPS::Request::DeliveryConfirmationCertify.tap do |klass|
|
6
|
-
klass.secure.
|
7
|
-
klass.api.
|
8
|
-
klass.tag.
|
6
|
+
expect(klass.secure).to be_truthy
|
7
|
+
expect(klass.api).to eq('DelivConfirmCertifyV3')
|
8
|
+
expect(klass.tag).to eq('DelivConfirmCertifyV3.0Request')
|
9
9
|
end
|
10
10
|
end
|
11
11
|
end
|
@@ -3,9 +3,9 @@ require 'spec_helper'
|
|
3
3
|
describe USPS::Request::DeliveryConfirmation do
|
4
4
|
it 'should be using the proper USPS api settings' do
|
5
5
|
USPS::Request::DeliveryConfirmation.tap do |klass|
|
6
|
-
klass.secure.
|
7
|
-
klass.api.
|
8
|
-
klass.tag.
|
6
|
+
expect(klass.secure).to be_truthy
|
7
|
+
expect(klass.api).to eq('DeliveryConfirmationV3')
|
8
|
+
expect(klass.tag).to eq('DeliveryConfirmationV3.0Request')
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
@@ -29,29 +29,29 @@ describe USPS::Request::DeliveryConfirmation do
|
|
29
29
|
request = USPS::Request::DeliveryConfirmation.new(to, from, 2).build
|
30
30
|
|
31
31
|
xml = Nokogiri::XML.parse(request)
|
32
|
-
xml.search('Option').text.
|
33
|
-
xml.search('ImageParameters').text.
|
34
|
-
|
35
|
-
xml.search('FromName').text.
|
36
|
-
xml.search('FromFirm').text.
|
37
|
-
xml.search('FromAddress1').text.
|
38
|
-
xml.search('FromAddress2').text.
|
39
|
-
xml.search('FromCity').text.
|
40
|
-
xml.search('FromState').text.
|
41
|
-
xml.search('FromZip5').text.
|
42
|
-
xml.search('FromZip4').text.
|
43
|
-
|
44
|
-
xml.search('ToName').text.
|
45
|
-
xml.search('ToFirm').text.
|
46
|
-
xml.search('ToAddress1').text.
|
47
|
-
xml.search('ToAddress2').text.
|
48
|
-
xml.search('ToCity').text.
|
49
|
-
xml.search('ToState').text.
|
50
|
-
xml.search('ToZip5').text.
|
51
|
-
xml.search('ToZip4').text.
|
52
|
-
|
53
|
-
xml.search('WeightInOunces').text.
|
54
|
-
xml.search('ImageType').text.
|
55
|
-
xml.search('ServiceType').text.
|
32
|
+
expect(xml.search('Option').text).to eq('1')
|
33
|
+
expect(xml.search('ImageParameters').text).to eq('')
|
34
|
+
|
35
|
+
expect(xml.search('FromName').text).to eq('John Smith')
|
36
|
+
expect(xml.search('FromFirm').text).to eq('')
|
37
|
+
expect(xml.search('FromAddress1').text).to eq('')
|
38
|
+
expect(xml.search('FromAddress2').text).to eq("475 L'Enfant Plaza, SW")
|
39
|
+
expect(xml.search('FromCity').text).to eq('Washington')
|
40
|
+
expect(xml.search('FromState').text).to eq('DC')
|
41
|
+
expect(xml.search('FromZip5').text).to eq('20260')
|
42
|
+
expect(xml.search('FromZip4').text).to eq('')
|
43
|
+
|
44
|
+
expect(xml.search('ToName').text).to eq('Joe Customer')
|
45
|
+
expect(xml.search('ToFirm').text).to eq('')
|
46
|
+
expect(xml.search('ToAddress1').text).to eq('STE 201')
|
47
|
+
expect(xml.search('ToAddress2').text).to eq('6060 PRIMACY PKWY')
|
48
|
+
expect(xml.search('ToCity').text).to eq('MEMPHIS')
|
49
|
+
expect(xml.search('ToState').text).to eq('TN')
|
50
|
+
expect(xml.search('ToZip5').text).to eq('')
|
51
|
+
expect(xml.search('ToZip4').text).to eq('')
|
52
|
+
|
53
|
+
expect(xml.search('WeightInOunces').text).to eq('2')
|
54
|
+
expect(xml.search('ImageType').text).to eq('TIF')
|
55
|
+
expect(xml.search('ServiceType').text).to eq('Priority')
|
56
56
|
end
|
57
57
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe USPS::Request::TrackingFieldLookup do
|
4
|
+
|
5
|
+
it 'should be using the proper USPS api settings' do
|
6
|
+
USPS::Request::TrackingFieldLookup.tap do |klass|
|
7
|
+
expect(klass.secure).to be_falsey
|
8
|
+
expect(klass.api).to eq('TrackV2')
|
9
|
+
expect(klass.tag).to eq('TrackFieldRequest')
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should build a proper request" do
|
14
|
+
request = USPS::Request::TrackingFieldLookup.new("EJ958083578US").build
|
15
|
+
xml = Nokogiri::XML.parse(request)
|
16
|
+
expect(xml.search('TrackID').text).to eq('')
|
17
|
+
expect(xml.search('TrackID').attr("ID").text).to eq("EJ958083578US")
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
@@ -4,9 +4,9 @@ describe USPS::Request::TrackingLookup do
|
|
4
4
|
|
5
5
|
it 'should be using the proper USPS api settings' do
|
6
6
|
USPS::Request::TrackingLookup.tap do |klass|
|
7
|
-
klass.secure.
|
8
|
-
klass.api.
|
9
|
-
klass.tag.
|
7
|
+
expect(klass.secure).to be_falsey
|
8
|
+
expect(klass.api).to eq('TrackV2')
|
9
|
+
expect(klass.tag).to eq('TrackRequest')
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
@@ -14,8 +14,8 @@ describe USPS::Request::TrackingLookup do
|
|
14
14
|
request = USPS::Request::TrackingLookup.new("EJ958083578US").build
|
15
15
|
|
16
16
|
xml = Nokogiri::XML.parse(request)
|
17
|
-
xml.search('TrackID').text.
|
18
|
-
xml.search('TrackID').attr("ID").text.
|
17
|
+
expect(xml.search('TrackID').text).to eq('')
|
18
|
+
expect(xml.search('TrackID').attr("ID").text).to eq("EJ958083578US")
|
19
19
|
end
|
20
20
|
|
21
21
|
end
|
@@ -3,16 +3,16 @@ require 'spec_helper'
|
|
3
3
|
describe USPS::Request::ZipCodeLookup do
|
4
4
|
it "should be using the proper USPS api settings" do
|
5
5
|
USPS::Request::ZipCodeLookup.tap do |klass|
|
6
|
-
klass.secure.
|
7
|
-
klass.api.
|
8
|
-
klass.tag.
|
6
|
+
expect(klass.secure).to be_falsey
|
7
|
+
expect(klass.api).to eq('ZipCodeLookup')
|
8
|
+
expect(klass.tag).to eq('ZipCodeLookupRequest')
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
12
|
it "should not allow more than 5 addresses" do
|
13
|
-
|
13
|
+
expect do
|
14
14
|
USPS::Request::AddressStandardization.new([USPS::Address.new] * 6)
|
15
|
-
end.
|
15
|
+
end.to raise_exception(ArgumentError)
|
16
16
|
end
|
17
17
|
|
18
18
|
it "should be able to build a proper request" do
|
@@ -30,13 +30,13 @@ describe USPS::Request::ZipCodeLookup do
|
|
30
30
|
xml = Nokogiri::XML.parse(request.build)
|
31
31
|
|
32
32
|
xml.search('Address').first.tap do |node|
|
33
|
-
node.attr('ID').
|
33
|
+
expect(node.attr('ID')).to eq('0')
|
34
34
|
|
35
|
-
node.search('FirmName').text.
|
36
|
-
node.search('Address1').text.
|
37
|
-
node.search('Address2').text.
|
38
|
-
node.search('City').text.
|
39
|
-
node.search('State').text.
|
35
|
+
expect(node.search('FirmName').text).to eq('Widget Tel Co.')
|
36
|
+
expect(node.search('Address1').text).to eq('Suite 2000')
|
37
|
+
expect(node.search('Address2').text).to eq('999 Serious Business Av')
|
38
|
+
expect(node.search('City').text).to eq('Awesome Town')
|
39
|
+
expect(node.search('State').text).to eq('FL')
|
40
40
|
end
|
41
41
|
end
|
42
42
|
end
|
@@ -14,10 +14,10 @@ describe USPS::Response::AddressStandardization do
|
|
14
14
|
|
15
15
|
standard = response.get(address)
|
16
16
|
|
17
|
-
standard.address.
|
18
|
-
standard.city.
|
19
|
-
standard.state.
|
20
|
-
standard.zip.
|
17
|
+
expect(standard.address).to eq('6406 IVY LN')
|
18
|
+
expect(standard.city).to eq('GREENBELT')
|
19
|
+
expect(standard.state).to eq('MD')
|
20
|
+
expect(standard.zip).to eq('20770-1441')
|
21
21
|
end
|
22
22
|
|
23
23
|
it "should handle test request 2" do
|
@@ -34,10 +34,10 @@ describe USPS::Response::AddressStandardization do
|
|
34
34
|
|
35
35
|
standard = response.get(address)
|
36
36
|
|
37
|
-
standard.address.
|
38
|
-
standard.city.
|
39
|
-
standard.state.
|
40
|
-
standard.zip.
|
37
|
+
expect(standard.address).to eq('8 WILDWOOD DR')
|
38
|
+
expect(standard.city).to eq('OLD LYME')
|
39
|
+
expect(standard.state).to eq('CT')
|
40
|
+
expect(standard.zip).to eq('06371-1844')
|
41
41
|
end
|
42
42
|
|
43
43
|
it "should propogate name to the result address as it is not returned from api" do
|
@@ -49,6 +49,6 @@ describe USPS::Response::AddressStandardization do
|
|
49
49
|
address, load_xml('address_standardization_2.xml')
|
50
50
|
)
|
51
51
|
|
52
|
-
response.get(address).name.
|
52
|
+
expect(response.get(address).name).to eq('Carl Sagan')
|
53
53
|
end
|
54
54
|
end
|
@@ -7,9 +7,9 @@ describe USPS::Response::CityAndStateLookup do
|
|
7
7
|
)
|
8
8
|
|
9
9
|
response.get(90210).tap do |r|
|
10
|
-
r.zip.
|
11
|
-
r.city.
|
12
|
-
r.state.
|
10
|
+
expect(r.zip).to eq(90210)
|
11
|
+
expect(r.city).to eq('BEVERLY HILLS')
|
12
|
+
expect(r.state).to eq('CA')
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
@@ -19,9 +19,9 @@ describe USPS::Response::CityAndStateLookup do
|
|
19
19
|
)
|
20
20
|
|
21
21
|
response.get(20770).tap do |r|
|
22
|
-
r.zip.
|
23
|
-
r.city.
|
24
|
-
r.state.
|
22
|
+
expect(r.zip).to eq(20770)
|
23
|
+
expect(r.city).to eq('GREENBELT')
|
24
|
+
expect(r.state).to eq('MD')
|
25
25
|
end
|
26
26
|
end
|
27
27
|
end
|
@@ -6,18 +6,18 @@ describe USPS::Response::DeliveryConfirmation do
|
|
6
6
|
load_xml('delivery_confirmation_1.xml')
|
7
7
|
)
|
8
8
|
|
9
|
-
response.confirmation.
|
10
|
-
response.label.
|
11
|
-
response.postnet.
|
9
|
+
expect(response.confirmation).to eq('420381199101805213907126809651')
|
10
|
+
expect(response.label).to eq('LABEL DATA GOES HERE')
|
11
|
+
expect(response.postnet).to eq('38119571851')
|
12
12
|
|
13
13
|
# Check the address
|
14
14
|
addy = response.address
|
15
|
-
addy.name.
|
16
|
-
addy.address.
|
17
|
-
addy.address2.
|
18
|
-
addy.city.
|
19
|
-
addy.state.
|
20
|
-
addy.zip.
|
15
|
+
expect(addy.name).to eq('Joe Customer')
|
16
|
+
expect(addy.address).to eq('6060 PRIMACY PKWY')
|
17
|
+
expect(addy.address2).to eq('STE 201')
|
18
|
+
expect(addy.city).to eq('Memphis')
|
19
|
+
expect(addy.state).to eq('TN')
|
20
|
+
expect(addy.zip).to eq('38119-5718')
|
21
21
|
end
|
22
22
|
|
23
23
|
# TODO: Test is still missing custom fields
|
@@ -26,18 +26,18 @@ describe USPS::Response::DeliveryConfirmation do
|
|
26
26
|
load_xml('delivery_confirmation_2.xml')
|
27
27
|
)
|
28
28
|
|
29
|
-
response.confirmation.
|
30
|
-
response.label.
|
31
|
-
response.postnet.
|
29
|
+
expect(response.confirmation).to eq('420381199101805213907116323891')
|
30
|
+
expect(response.label).to eq('LABEL DATA GOES HERE')
|
31
|
+
expect(response.postnet).to eq('38119571851')
|
32
32
|
|
33
33
|
# Check the address
|
34
34
|
addy = response.address
|
35
|
-
addy.company.
|
36
|
-
addy.name.
|
37
|
-
addy.address.
|
38
|
-
addy.address2.
|
39
|
-
addy.city.
|
40
|
-
addy.state.
|
41
|
-
addy.zip.
|
35
|
+
expect(addy.company).to eq('U.S. Postal Service NCSC')
|
36
|
+
expect(addy.name).to eq('Joe Customer')
|
37
|
+
expect(addy.address).to eq('6060 PRIMACY PKWY')
|
38
|
+
expect(addy.address2).to eq('STE 201')
|
39
|
+
expect(addy.city).to eq('MEMPHIS')
|
40
|
+
expect(addy.state).to eq('TN')
|
41
|
+
expect(addy.zip).to eq('38119-5718')
|
42
42
|
end
|
43
43
|
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe USPS::Response::TrackingFieldLookup do
|
4
|
+
|
5
|
+
it "should handle test request" do
|
6
|
+
response = USPS::Response::TrackingFieldLookup.new(load_xml("tracking_field_lookup.xml"))
|
7
|
+
expect(response).to be_a_kind_of(USPS::Response::TrackingFieldLookup)
|
8
|
+
|
9
|
+
expect(response.summary.event).to eq("DELIVERED")
|
10
|
+
expect(response.summary.city).to eq("NEWTON")
|
11
|
+
expect(response.summary.date).to eq(Time.parse("2001-05-21 12:12:00 -0400"))
|
12
|
+
expect(response.summary.event_time).to eq("12:12 pm")
|
13
|
+
expect(response.summary.event_date).to eq("May 21, 2001")
|
14
|
+
expect(response.summary.event_state).to eq("IA")
|
15
|
+
expect(response.summary.event_zip_code).to eq("50208")
|
16
|
+
expect(response.summary.name).to eq("")
|
17
|
+
expect(response.summary.firm_name).to eq("")
|
18
|
+
expect(response.summary.authorized_agent).to eq("")
|
19
|
+
|
20
|
+
expect(response.details.length).to eq(2)
|
21
|
+
expect(response.details[0].event).to eq("ENROUTE")
|
22
|
+
expect(response.details[1].event).to eq("ACCEPTANCE")
|
23
|
+
end
|
24
|
+
it "should handle no detail records" do
|
25
|
+
response = USPS::Response::TrackingFieldLookup.new(load_xml("tracking_field_lookup_2.xml"))
|
26
|
+
expect(response.details.length).to eq(0)
|
27
|
+
end
|
28
|
+
end
|
@@ -5,23 +5,23 @@ describe USPS::Response::TrackingLookup do
|
|
5
5
|
it "should handle test request 1" do
|
6
6
|
response = USPS::Response::TrackingLookup.new(load_xml("tracking_lookup_1.xml"))
|
7
7
|
|
8
|
-
response.summary.
|
9
|
-
response.details.length.
|
8
|
+
expect(response.summary).to eq("Your item was delivered at 8:10 am on June 1 in Wilmington DE 19801.")
|
9
|
+
expect(response.details.length).to eq(3)
|
10
10
|
|
11
|
-
response.details[0].
|
12
|
-
response.details[1].
|
13
|
-
response.details[2].
|
11
|
+
expect(response.details[0]).to eq("May 30 11:07 am NOTICE LEFT WILMINGTON DE 19801.")
|
12
|
+
expect(response.details[1]).to eq("May 30 10:08 am ARRIVAL AT UNIT WILMINGTON DE 19850.")
|
13
|
+
expect(response.details[2]).to eq("May 29 9:55 am ACCEPT OR PICKUP EDGEWATER NJ 07020.")
|
14
14
|
end
|
15
15
|
|
16
16
|
it "should handle test request 2" do
|
17
17
|
response = USPS::Response::TrackingLookup.new(load_xml("tracking_lookup_2.xml"))
|
18
18
|
|
19
|
-
response.summary.
|
20
|
-
response.details.length.
|
19
|
+
expect(response.summary).to eq("Your item was delivered at 1:39 pm on June 1 in WOBURN MA 01815.")
|
20
|
+
expect(response.details.length).to eq(3)
|
21
21
|
|
22
|
-
response.details[0].
|
23
|
-
response.details[1].
|
24
|
-
response.details[2].
|
22
|
+
expect(response.details[0]).to eq("May 30 7:44 am NOTICE LEFT WOBURN MA 01815.")
|
23
|
+
expect(response.details[1]).to eq("May 30 7:36 am ARRIVAL AT UNIT NORTH READING MA 01889.")
|
24
|
+
expect(response.details[2]).to eq("May 29 6:00 pm ACCEPT OR PICKUP PORTSMOUTH NH 03801.")
|
25
25
|
end
|
26
26
|
|
27
27
|
end
|