easypost 2.1.0 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/spec/user_spec.rb ADDED
@@ -0,0 +1,88 @@
1
+ require 'spec_helper'
2
+
3
+ describe EasyPost::User do
4
+ before do
5
+ EasyPost.api_key = "PRODUCTION API KEY"
6
+ end
7
+
8
+ # This test requires APIKEY to be nil
9
+ # it 'creates a new user' do
10
+ # EasyPost.api_key = nil
11
+
12
+ # user = EasyPost::User.create({
13
+ # name: "Chad Vader",
14
+ # email: 'c.vader3@example.com',
15
+ # password: "4theempire",
16
+ # password_confirmation: "4theempire",
17
+ # phone_number: '555-123-4321'
18
+ # })
19
+
20
+ # expect(user.id).not_to be_nil
21
+ # end
22
+
23
+
24
+ # Uncomment these tests to test CRUD operations on the User model
25
+ # Note: You must provide a Production Api Key in order to run these tests
26
+
27
+ # it 'performs all basic CRUD actions on a User' do
28
+ # me = EasyPost::User.retrieve_me
29
+ # original_children_count = me.children.count
30
+
31
+ # name = 'Ruby All-Things-Testing'
32
+
33
+ # sub_user = EasyPost::User.create(
34
+ # name: name,
35
+ # password: 'password1',
36
+ # password_confirmation: 'password1',
37
+ # phone_number: '7778675309'
38
+ # )
39
+
40
+ # id = sub_user.id
41
+ # email = sub_user.email
42
+
43
+ # retrieved_user = EasyPost::User.retrieve(id)
44
+ # expect(retrieved_user.id).to eq(id)
45
+ # expect(retrieved_user.email).to eq(email)
46
+ # expect(retrieved_user.name).to eq(name)
47
+
48
+ # new_me = EasyPost::User.retrieve_me
49
+ # interm_children_count = new_me.children.count
50
+ # expect(interm_children_count).to eq(original_children_count + 1)
51
+
52
+ # new_name = 'Ruby All-Things-Tested'
53
+ # retrieved_user.name = new_name
54
+ # retrieved_user.save
55
+
56
+ # updated_user = EasyPost::User.retrieve(id)
57
+ # expect(updated_user.id).to eq(id)
58
+ # expect(updated_user.email).to eq(email)
59
+ # expect(updated_user.name).to eq(new_name)
60
+ # end
61
+
62
+ # describe '#all_api_keys' do
63
+ # it 'returns the correct set of api_keys' do
64
+ # api_keys = EasyPost::User.all_api_keys
65
+
66
+ # my_keys = api_keys.keys
67
+ # expect(my_keys.first.mode).to eq("production")
68
+ # expect(my_keys.last.mode).to eq("test")
69
+
70
+ # me = EasyPost::User.retrieve_me
71
+ # children_count = me.children.count
72
+
73
+ # expect(api_keys.children.count).to eq(children_count)
74
+ # end
75
+ # end
76
+
77
+ # describe '#api_keys' do
78
+ # it 'returns different keys for the parent and child users' do
79
+ # me = EasyPost::User.retrieve_me
80
+ # my_keys = me.api_keys
81
+
82
+ # child = me.children.first
83
+ # child_keys = child.api_keys
84
+
85
+ # expect(my_keys).not_to eq(child_keys)
86
+ # end
87
+ # end
88
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: easypost
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sawyer Bateman
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-11 00:00:00.000000000 Z
11
+ date: 2016-07-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -28,22 +28,16 @@ dependencies:
28
28
  name: multi_json
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ! '>='
31
+ - - '>='
32
32
  - !ruby/object:Gem::Version
33
- version: 1.0.4
34
- - - <
35
- - !ruby/object:Gem::Version
36
- version: '2'
33
+ version: 1.3.0
37
34
  type: :runtime
38
35
  prerelease: false
39
36
  version_requirements: !ruby/object:Gem::Requirement
40
37
  requirements:
41
- - - ! '>='
42
- - !ruby/object:Gem::Version
43
- version: 1.0.4
44
- - - <
38
+ - - '>='
45
39
  - !ruby/object:Gem::Version
46
- version: '2'
40
+ version: 1.3.0
47
41
  - !ruby/object:Gem::Dependency
48
42
  name: bundler
49
43
  requirement: !ruby/object:Gem::Requirement
@@ -78,14 +72,14 @@ dependencies:
78
72
  requirements:
79
73
  - - ~>
80
74
  - !ruby/object:Gem::Version
81
- version: 2.13.0
75
+ version: '2.13'
82
76
  type: :development
83
77
  prerelease: false
84
78
  version_requirements: !ruby/object:Gem::Requirement
85
79
  requirements:
86
80
  - - ~>
87
81
  - !ruby/object:Gem::Version
88
- version: 2.13.0
82
+ version: '2.13'
89
83
  description: Client library for accessing the EasyPost shipping API via Ruby.
90
84
  email: contact@easypost.com
91
85
  executables:
@@ -105,11 +99,13 @@ files:
105
99
  - lib/easypost.rb
106
100
  - lib/easypost/address.rb
107
101
  - lib/easypost/batch.rb
102
+ - lib/easypost/carrier_account.rb
108
103
  - lib/easypost/container.rb
109
104
  - lib/easypost/customs_info.rb
110
105
  - lib/easypost/customs_item.rb
111
106
  - lib/easypost/error.rb
112
107
  - lib/easypost/event.rb
108
+ - lib/easypost/insurance.rb
113
109
  - lib/easypost/item.rb
114
110
  - lib/easypost/object.rb
115
111
  - lib/easypost/order.rb
@@ -117,29 +113,30 @@ files:
117
113
  - lib/easypost/pickup.rb
118
114
  - lib/easypost/pickup_rate.rb
119
115
  - lib/easypost/postage_label.rb
116
+ - lib/easypost/print_job.rb
117
+ - lib/easypost/printer.rb
120
118
  - lib/easypost/rate.rb
121
119
  - lib/easypost/refund.rb
122
120
  - lib/easypost/resource.rb
123
121
  - lib/easypost/scan_form.rb
124
122
  - lib/easypost/shipment.rb
125
123
  - lib/easypost/tracker.rb
124
+ - lib/easypost/user.rb
126
125
  - lib/easypost/util.rb
127
126
  - lib/easypost/version.rb
128
127
  - spec/address_spec.rb
129
128
  - spec/batch_spec.rb
129
+ - spec/carrier_account_spec.rb
130
130
  - spec/container_spec.rb
131
- - spec/fedex/domestic_spec.rb
132
- - spec/fedex/international_spec.rb
131
+ - spec/insurance_spec.rb
133
132
  - spec/item_spec.rb
134
133
  - spec/order_spec.rb
135
134
  - spec/pickup_spec.rb
136
135
  - spec/shipment_spec.rb
137
136
  - spec/spec_helper.rb
138
- - spec/ups/domestic_spec.rb
139
- - spec/ups/international_spec.rb
140
- - spec/usps/domestic_spec.rb
141
- - spec/usps/electronic_merchandise_returns.rb
142
- - spec/usps/merchant_returns.rb
137
+ - spec/support/constant.rb
138
+ - spec/tracker_spec.rb
139
+ - spec/user_spec.rb
143
140
  homepage: https://www.easypost.com/docs
144
141
  licenses: []
145
142
  metadata: {}
@@ -149,33 +146,31 @@ require_paths:
149
146
  - lib
150
147
  required_ruby_version: !ruby/object:Gem::Requirement
151
148
  requirements:
152
- - - ! '>='
149
+ - - '>='
153
150
  - !ruby/object:Gem::Version
154
151
  version: '0'
155
152
  required_rubygems_version: !ruby/object:Gem::Requirement
156
153
  requirements:
157
- - - ! '>='
154
+ - - '>='
158
155
  - !ruby/object:Gem::Version
159
156
  version: '0'
160
157
  requirements: []
161
158
  rubyforge_project:
162
- rubygems_version: 2.2.2
159
+ rubygems_version: 2.0.14.1
163
160
  signing_key:
164
161
  specification_version: 4
165
162
  summary: EasyPost Ruby Client Library
166
163
  test_files:
167
164
  - spec/address_spec.rb
168
165
  - spec/batch_spec.rb
166
+ - spec/carrier_account_spec.rb
169
167
  - spec/container_spec.rb
170
- - spec/fedex/domestic_spec.rb
171
- - spec/fedex/international_spec.rb
168
+ - spec/insurance_spec.rb
172
169
  - spec/item_spec.rb
173
170
  - spec/order_spec.rb
174
171
  - spec/pickup_spec.rb
175
172
  - spec/shipment_spec.rb
176
173
  - spec/spec_helper.rb
177
- - spec/ups/domestic_spec.rb
178
- - spec/ups/international_spec.rb
179
- - spec/usps/domestic_spec.rb
180
- - spec/usps/electronic_merchandise_returns.rb
181
- - spec/usps/merchant_returns.rb
174
+ - spec/support/constant.rb
175
+ - spec/tracker_spec.rb
176
+ - spec/user_spec.rb
@@ -1,180 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe 'fedex domestic' do
4
- before(:all) do
5
- @rates = {}
6
- end
7
-
8
- it 'buys a commercial ground label' do
9
- shipment = EasyPost::Shipment.create(
10
- :to_address => ADDRESS[:california],
11
- :from_address => ADDRESS[:missouri],
12
- :parcel => PARCEL[:dimensions]
13
- )
14
- shipment.buy(:rate => shipment.lowest_rate("fedex", "FEDEX_GROUND"))
15
- label = open(shipment.postage_label.label_url)
16
-
17
- expect(shipment).to be_an_instance_of(EasyPost::Shipment)
18
- expect(shipment.selected_rate).to be_an_instance_of(EasyPost::Rate)
19
- expect(shipment.selected_rate.service).to eq("FEDEX_GROUND")
20
- expect(shipment.postage_label.label_url).to end_with(".png")
21
- expect(shipment.tracking_code).to start_with("8000")
22
- expect(label.size).to be > 5000
23
-
24
- @rates[:commercial] = shipment.selected_rate
25
- end
26
-
27
- it 'buys a residential ground label' do
28
- shipment = EasyPost::Shipment.create(
29
- :to_address => ADDRESS[:california],
30
- :from_address => ADDRESS[:missouri],
31
- :parcel => PARCEL[:dimensions],
32
- :options => {:residential_to_address => true}
33
- )
34
- shipment.buy(:rate => shipment.lowest_rate("fedex", "GROUND_HOME_DELIVERY"))
35
- label = open(shipment.postage_label.label_url)
36
-
37
- expect(shipment.selected_rate.service).to eq("GROUND_HOME_DELIVERY")
38
- expect(shipment.tracking_code).to start_with("8000")
39
- expect(label.size).to be > 5000
40
-
41
- @rates[:residential] = shipment.selected_rate
42
- end
43
-
44
- it 'buys a ground evening delivery label' do
45
- shipment = EasyPost::Shipment.create(
46
- :to_address => ADDRESS[:california],
47
- :from_address => ADDRESS[:missouri],
48
- :parcel => PARCEL[:dimensions],
49
- :options => {:residential_to_address => true,
50
- :delivery_time_preference => "evening"}
51
- )
52
- shipment.buy(:rate => shipment.lowest_rate("fedex", "GROUND_HOME_DELIVERY"))
53
-
54
- expect(shipment.postage_label.label_url).to end_with(".png")
55
-
56
- @rates[:residential_evening] = shipment.selected_rate
57
- end
58
-
59
- it 'raises error without recipient phone number' do
60
- shipment = EasyPost::Shipment.create(
61
- :to_address => ADDRESS[:california_no_phone],
62
- :from_address => ADDRESS[:missouri],
63
- :parcel => PARCEL[:dimensions]
64
- )
65
-
66
- expect { shipment.buy(rate: shipment.lowest_rate("fedex")) }.to raise_error(EasyPost::Error, /Unable to buy FedEx shipment without recipient phone number./)
67
- end
68
-
69
- it 'buys a label for an alcoholic shipment with epl2 label' do
70
- shipment = EasyPost::Shipment.create(
71
- :to_address => ADDRESS[:california],
72
- :from_address => ADDRESS[:missouri],
73
- :parcel => PARCEL[:dimensions],
74
- :options => {
75
- :alcohol => 1,
76
- :label_format => "epl2"
77
- }
78
- )
79
- shipment.buy(:rate => shipment.lowest_rate("fedex", "PRIORITY_OVERNIGHT"))
80
-
81
- expect(shipment.postage_label.label_url).to end_with(".epl2")
82
- end
83
-
84
- it 'buys a label for a ground cod shipment' do
85
- shipment = EasyPost::Shipment.create(
86
- :to_address => ADDRESS[:california],
87
- :from_address => ADDRESS[:missouri],
88
- :parcel => PARCEL[:dimensions]
89
- )
90
- shipment_cod = EasyPost::Shipment.create(
91
- :to_address => ADDRESS[:california],
92
- :from_address => ADDRESS[:missouri],
93
- :parcel => PARCEL[:dimensions],
94
- :options => {cod_amount: 19.99}
95
- )
96
- shipment_cod.buy(rate: shipment_cod.lowest_rate("fedex", "FEDEX_GROUND"))
97
-
98
- expect(shipment.lowest_rate("fedex", "FEDEX_GROUND").rate.to_f).to be < (shipment_cod.lowest_rate("fedex", "FEDEX_GROUND").rate.to_f)
99
- expect(shipment.lowest_rate("fedex", "PRIORITY_OVERNIGHT").rate.to_f).to be < (shipment_cod.lowest_rate("fedex", "PRIORITY_OVERNIGHT").rate.to_f)
100
- expect(shipment_cod.postage_label.label_url).to be
101
- end
102
-
103
- it 'buys a label for a ground multi-parcel cod shipment' do
104
- order = EasyPost::Order.create(
105
- to_address: ADDRESS[:california],
106
- from_address: ADDRESS[:missouri],
107
- shipments: [{
108
- parcel: {length: 8, width: 6, height: 4, weight: 12},
109
- options: {cod_amount: 14.99}
110
- },{
111
- parcel: {length: 8, width: 6, height: 4, weight: 12},
112
- options: {cod_amount: 18.75}
113
- }]
114
- )
115
- order.buy(carrier: "fedex", service: "FEDEX_GROUND")
116
-
117
- expect(order).to be_an_instance_of(EasyPost::Order)
118
- expect(order.shipments.first).to be_an_instance_of(EasyPost::Shipment)
119
- expect(order.shipments[0].postage_label.label_url).to be
120
- expect(order.shipments[1].postage_label.label_url).to be
121
- end
122
-
123
- it 'buys a label for an express cod shipment' do
124
- shipment = EasyPost::Shipment.create(
125
- :to_address => ADDRESS[:california],
126
- :from_address => ADDRESS[:missouri],
127
- :parcel => PARCEL[:dimensions]
128
- )
129
- shipment_cod = EasyPost::Shipment.create(
130
- :to_address => ADDRESS[:california],
131
- :from_address => ADDRESS[:missouri],
132
- :parcel => PARCEL[:dimensions],
133
- :options => {cod_amount: 19.99}
134
- )
135
- shipment_cod.buy(rate: shipment_cod.lowest_rate("fedex", "PRIORITY_OVERNIGHT"))
136
-
137
- expect(shipment.lowest_rate("fedex", "FEDEX_GROUND").rate.to_f).to be < (shipment_cod.lowest_rate("fedex", "FEDEX_GROUND").rate.to_f)
138
- expect(shipment.lowest_rate("fedex", "PRIORITY_OVERNIGHT").rate.to_f).to be < (shipment_cod.lowest_rate("fedex", "PRIORITY_OVERNIGHT").rate.to_f)
139
- expect(shipment_cod.postage_label.label_url).to be
140
- end
141
-
142
- it 'buys a label for an express multi-parcel cod shipment' do
143
- order = EasyPost::Order.create(
144
- to_address: ADDRESS[:california],
145
- from_address: ADDRESS[:missouri],
146
- shipments: [{
147
- parcel: {length: 8, width: 6, height: 4, weight: 12},
148
- options: {cod_amount: 14.99}
149
- },{
150
- parcel: {length: 8, width: 6, height: 4, weight: 12},
151
- options: {cod_amount: 18.75}
152
- }]
153
- )
154
- order.buy(carrier: "fedex", service: "PRIORITY_OVERNIGHT")
155
-
156
- expect(order).to be_an_instance_of(EasyPost::Order)
157
- expect(order.shipments.first).to be_an_instance_of(EasyPost::Shipment)
158
- expect(order.shipments[0].postage_label.label_url).to be
159
- expect(order.shipments[1].postage_label.label_url).to be
160
- end
161
-
162
- it 'buys a label using a thid party account number' do
163
- shipment = EasyPost::Shipment.create(
164
- :to_address => ADDRESS[:california],
165
- :from_address => ADDRESS[:missouri],
166
- :parcel => PARCEL[:dimensions],
167
- :options => {:bill_third_party_account => "12345678"}
168
- )
169
- expect { shipment.buy(rate: shipment.lowest_rate("fedex")) }.to raise_error(EasyPost::Error, /ShippingChargesPayment Payor - The payor's account number is invalid/)
170
- end
171
-
172
- after(:all) do
173
- begin
174
- expect(@rates[:residential_evening].rate.to_i).to be > @rates[:residential].rate.to_i
175
- expect(@rates[:residential].rate.to_i).to be > @rates[:commercial].rate.to_i
176
- rescue
177
- end
178
- end
179
-
180
- end
@@ -1,64 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe 'fedex international' do
4
- before(:all) do
5
- @rates = {}
6
- end
7
-
8
- it 'buys a ground label' do
9
- shipment = EasyPost::Shipment.create(
10
- :to_address => ADDRESS[:canada],
11
- :from_address => ADDRESS[:california],
12
- :parcel => PARCEL[:dimensions],
13
- :customs_info => CUSTOMS_INFO[:shirt]
14
- )
15
- shipment.buy(:rate => shipment.lowest_rate("fedex", "FEDEX_GROUND"))
16
- label = open(shipment.postage_label.label_url)
17
-
18
- expect(shipment).to be_an_instance_of(EasyPost::Shipment)
19
- expect(shipment.selected_rate).to be_an_instance_of(EasyPost::Rate)
20
- expect(shipment.selected_rate.service).to eq("FEDEX_GROUND")
21
- expect(shipment.postage_label.label_url).to end_with(".png")
22
- expect(shipment.tracking_code).to start_with("8000")
23
- expect(label.size).to be > 5000
24
-
25
- @rates[:ground] = shipment.selected_rate
26
- end
27
-
28
- it 'buys an air label' do
29
- shipment = EasyPost::Shipment.create(
30
- :to_address => ADDRESS[:canada],
31
- :from_address => ADDRESS[:california],
32
- :parcel => PARCEL[:dimensions],
33
- :customs_info => CUSTOMS_INFO[:shirt]
34
- )
35
- shipment.buy(:rate => shipment.lowest_rate("fedex", "INTERNATIONAL_PRIORITY"))
36
- label = open(shipment.postage_label.label_url)
37
-
38
- expect(shipment.selected_rate.service).to eq("INTERNATIONAL_PRIORITY")
39
- expect(shipment.tracking_code).to start_with("794")
40
- expect(label.size).to be > 20000
41
-
42
- @rates[:air] = shipment.selected_rate
43
- end
44
-
45
- it 'returns no rates for an alcohol shipment', focus: true do
46
- shipment = EasyPost::Shipment.create(
47
- :to_address => ADDRESS[:canada],
48
- :from_address => ADDRESS[:california],
49
- :parcel => PARCEL[:dimensions],
50
- :customs_info => CUSTOMS_INFO[:shirt],
51
- :options => {:alcohol => true}
52
- )
53
-
54
- expect { shipment.lowest_rate("fedex") }.to raise_exception(EasyPost::Error, /No rates found/)
55
- end
56
-
57
- after(:all) do
58
- begin
59
- expect(@rates[:air].rate.to_i).to be > @rates[:ground].rate.to_i
60
- rescue
61
- end
62
- end
63
-
64
- end
@@ -1,79 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe 'ups domestic' do
4
- before(:all) do
5
- @rates = {}
6
- end
7
-
8
- it 'buys an air label' do
9
- shipment = EasyPost::Shipment.create(
10
- :to_address => ADDRESS[:california],
11
- :from_address => ADDRESS[:missouri],
12
- :parcel => PARCEL[:dimensions]
13
- )
14
- shipment.buy(:rate => shipment.lowest_rate("ups", "NextDayAir"))
15
- label = open(shipment.postage_label.label_url)
16
-
17
-
18
- expect(shipment).to be_an_instance_of(EasyPost::Shipment)
19
- expect(shipment.selected_rate).to be_an_instance_of(EasyPost::Rate)
20
- expect(shipment.selected_rate.service).to eq("NextDayAir")
21
- expect(shipment.postage_label.label_url).to end_with(".png")
22
- expect(shipment.tracking_code).to start_with("1Z")
23
- expect(label.size).to be > 5000
24
-
25
- @rates[:next_day_air] = shipment.selected_rate
26
- end
27
-
28
- it 'buys a residential ground label' do
29
- shipment = EasyPost::Shipment.create(
30
- :to_address => ADDRESS[:california],
31
- :from_address => ADDRESS[:missouri],
32
- :parcel => PARCEL[:dimensions],
33
- :options => {:residential_to_address => true}
34
- )
35
- shipment.buy(:rate => shipment.lowest_rate("ups", "Ground"))
36
- label = open(shipment.postage_label.label_url)
37
-
38
- expect(shipment.selected_rate.service).to eq("Ground")
39
- expect(shipment.tracking_code).to start_with("1Z")
40
- expect(label.size).to be > 5000
41
-
42
- @rates[:ground] = shipment.selected_rate
43
- end
44
-
45
- it 'buys a label for an alcoholic shipment and epl2 label' do
46
- shipment = EasyPost::Shipment.create(
47
- :to_address => ADDRESS[:california],
48
- :from_address => ADDRESS[:missouri],
49
- :parcel => PARCEL[:dimensions],
50
- :options => {alcohol: true, label_format: "epl2"}
51
- )
52
- shipment.buy(:rate => shipment.lowest_rate("ups", "Ground"))
53
-
54
- expect(shipment.postage_label.label_url).to end_with(".epl2")
55
- end
56
-
57
- # it 'buys an order with shipment level cod', focus: true do
58
- # order = EasyPost::Order.create(
59
- # to_address: ADDRESS[:california],
60
- # from_address: ADDRESS[:missouri],
61
- # options: {cod_amount: 19.99},
62
- # shipments: [{
63
- # parcel: {length: 8, width: 6, height: 4, weight: 12}
64
- # },{
65
- # parcel: {length: 8, width: 6, height: 4, weight: 12}
66
- # }]
67
- # )
68
- # p order
69
- # # order.buy(carrier: "ups", service: "Ground")
70
- # end
71
-
72
- after(:all) do
73
- begin
74
- expect(@rates[:next_day_air].rate.to_i).to be > @rates[:ground].rate.to_i
75
- rescue
76
- end
77
- end
78
-
79
- end
@@ -1,64 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe 'ups international' do
4
- before(:all) do
5
- @rates = {}
6
- end
7
-
8
- it 'buys a UPSStandard label' do
9
- shipment = EasyPost::Shipment.create(
10
- :to_address => ADDRESS[:canada],
11
- :from_address => ADDRESS[:california],
12
- :parcel => PARCEL[:dimensions],
13
- :customs_info => CUSTOMS_INFO[:shirt]
14
- )
15
- shipment.buy(:rate => shipment.lowest_rate("ups", "UPSStandard"))
16
- label = open(shipment.postage_label.label_url)
17
-
18
- expect(shipment).to be_an_instance_of(EasyPost::Shipment)
19
- expect(shipment.selected_rate).to be_an_instance_of(EasyPost::Rate)
20
- expect(shipment.selected_rate.service).to eq("UPSStandard")
21
- expect(shipment.postage_label.label_url).to end_with(".png")
22
- expect(shipment.tracking_code).to start_with("1Z")
23
- expect(label.size).to be > 5000
24
-
25
- @rates[:ground] = shipment.selected_rate
26
- end
27
-
28
- it 'buys an air label' do
29
- shipment = EasyPost::Shipment.create(
30
- :to_address => ADDRESS[:canada],
31
- :from_address => ADDRESS[:california],
32
- :parcel => PARCEL[:dimensions],
33
- :customs_info => CUSTOMS_INFO[:shirt]
34
- )
35
- shipment.buy(:rate => shipment.lowest_rate("ups", "Expedited"))
36
- label = open(shipment.postage_label.label_url)
37
-
38
- expect(shipment.selected_rate.service).to eq("Expedited")
39
- expect(shipment.tracking_code).to start_with("1Z")
40
- expect(label.size).to be > 20000
41
-
42
- @rates[:express] = shipment.selected_rate
43
- end
44
-
45
- it 'returns no rates for an alcohol shipment' do
46
- shipment = EasyPost::Shipment.create(
47
- :to_address => ADDRESS[:canada],
48
- :from_address => ADDRESS[:california],
49
- :parcel => PARCEL[:dimensions],
50
- :customs_info => CUSTOMS_INFO[:shirt],
51
- :options => {:alcohol => true}
52
- )
53
-
54
- expect { shipment.lowest_rate("ups") }.to raise_exception(EasyPost::Error, /No rates found/)
55
- end
56
-
57
- after(:all) do
58
- begin
59
- expect(@rates[:air].rate.to_i).to be > @rates[:ground].rate.to_i
60
- rescue
61
- end
62
- end
63
-
64
- end
@@ -1,66 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe 'usps domestic' do
4
- before(:all) do
5
- @first = EasyPost::Shipment.create(
6
- :to_address => ADDRESS[:california],
7
- :from_address => ADDRESS[:missouri],
8
- :parcel => PARCEL[:dimensions_light]
9
- )
10
- @first.buy(:rate => @first.lowest_rate("usps", "first"))
11
-
12
- @priority = EasyPost::Shipment.create(
13
- :to_address => ADDRESS[:california],
14
- :from_address => ADDRESS[:missouri],
15
- :parcel => PARCEL[:dimensions]
16
- )
17
- @priority.buy(:rate => @priority.lowest_rate("usps", "priority"))
18
-
19
- @return = EasyPost::Shipment.create(
20
- :to_address => ADDRESS[:california],
21
- :from_address => ADDRESS[:missouri],
22
- :parcel => PARCEL[:dimensions],
23
- :is_return => true
24
- )
25
- @return.buy(:rate => @return.lowest_rate("usps", "priority"))
26
-
27
- end
28
-
29
- it 'buys a first label' do
30
- expect(@first).to be_an_instance_of(EasyPost::Shipment)
31
- expect(@first.selected_rate).to be_an_instance_of(EasyPost::Rate)
32
- expect(@first.selected_rate.service).to eq("First")
33
- expect(@first.postage_label.label_url).to end_with(".png")
34
- expect(@first.tracking_code).to eq("9499907123456123456781")
35
-
36
- label = open(@first.postage_label.label_url)
37
- expect(label.size).to be > 30000
38
- end
39
-
40
- it 'buys a priority label' do
41
- expect(@priority.selected_rate.service).to eq("Priority")
42
- expect(@priority.tracking_code).to eq("9499907123456123456781")
43
-
44
- label = open(@priority.postage_label.label_url)
45
- expect(label.size).to be > 30000
46
- end
47
-
48
- it 'buys a return label' do
49
- expect(@priority.selected_rate.service).to eq("Priority")
50
- expect(@priority.tracking_code).to eq("9499907123456123456781")
51
-
52
- label = open(@priority.postage_label.label_url)
53
- expect(label.size).to be > 30000
54
- end
55
-
56
- it 'omits rates for alcohol shipments' do
57
- shipment = EasyPost::Shipment.create(
58
- :to_address => ADDRESS[:california],
59
- :from_address => ADDRESS[:missouri],
60
- :parcel => PARCEL[:dimensions],
61
- :options => {:alcohol => true}
62
- )
63
- expect { shipment.buy(rate: shipment.lowest_rate('usps')) }.to raise_exception
64
- end
65
-
66
- end