active_shipping 1.0.0.pre4 → 1.0.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.
Files changed (76) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/.yardopts +0 -1
  5. data/CHANGELOG.md +17 -0
  6. data/CONTRIBUTING.md +2 -2
  7. data/Gemfile.activesupport32 +1 -0
  8. data/README.md +1 -1
  9. data/Rakefile +1 -1
  10. data/active_shipping.gemspec +2 -2
  11. data/lib/active_shipping.rb +2 -3
  12. data/lib/active_shipping/carriers.rb +1 -0
  13. data/lib/active_shipping/carriers/canada_post_pws.rb +281 -266
  14. data/lib/active_shipping/carriers/correios.rb +285 -0
  15. data/lib/active_shipping/carriers/fedex.rb +205 -199
  16. data/lib/active_shipping/carriers/stamps.rb +218 -219
  17. data/lib/active_shipping/carriers/ups.rb +287 -48
  18. data/lib/active_shipping/carriers/usps.rb +3 -3
  19. data/lib/active_shipping/delivery_date_estimate.rb +21 -0
  20. data/lib/active_shipping/delivery_date_estimates_response.rb +11 -0
  21. data/lib/active_shipping/errors.rb +20 -1
  22. data/lib/active_shipping/location.rb +0 -5
  23. data/lib/active_shipping/response.rb +0 -15
  24. data/lib/active_shipping/version.rb +1 -1
  25. data/test/credentials.yml +11 -3
  26. data/test/fixtures/xml/correios/book_response.xml +13 -0
  27. data/test/fixtures/xml/correios/book_response_invalid.xml +13 -0
  28. data/test/fixtures/xml/correios/clothes_response.xml +43 -0
  29. data/test/fixtures/xml/correios/poster_response.xml +23 -0
  30. data/test/fixtures/xml/correios/shoes_response.xml +43 -0
  31. data/test/fixtures/xml/fedex/tracking_request.xml +13 -11
  32. data/test/fixtures/xml/fedex/tracking_response_bad_tracking_number.xml +20 -0
  33. data/test/fixtures/xml/fedex/tracking_response_delivered_at_door.xml +254 -0
  34. data/test/fixtures/xml/fedex/tracking_response_delivered_at_facility.xml +403 -0
  35. data/test/fixtures/xml/fedex/tracking_response_delivered_with_signature.xml +269 -0
  36. data/test/fixtures/xml/fedex/tracking_response_in_transit.xml +127 -0
  37. data/test/fixtures/xml/fedex/tracking_response_multiple_results.xml +100 -0
  38. data/test/fixtures/xml/fedex/tracking_response_not_found.xml +52 -0
  39. data/test/fixtures/xml/fedex/tracking_response_shipment_exception.xml +209 -0
  40. data/test/fixtures/xml/ups/delivery_dates_response.xml +140 -0
  41. data/test/fixtures/xml/ups/package_exceeds_maximum_length.xml +12 -0
  42. data/test/fixtures/xml/ups/rate_single_service.xml +54 -0
  43. data/test/fixtures/xml/ups/rescheduled_shipment.xml +204 -0
  44. data/test/fixtures/xml/ups/test_real_home_as_residential_destination_response.xml +290 -1
  45. data/test/fixtures/xml/usps/delivered_extended_tracking_response.xml +11 -0
  46. data/test/remote/canada_post_pws_platform_test.rb +35 -22
  47. data/test/remote/canada_post_pws_test.rb +32 -40
  48. data/test/remote/correios_test.rb +83 -0
  49. data/test/remote/fedex_test.rb +95 -13
  50. data/test/remote/stamps_test.rb +1 -0
  51. data/test/remote/ups_test.rb +77 -40
  52. data/test/remote/usps_test.rb +13 -1
  53. data/test/test_helper.rb +12 -2
  54. data/test/unit/carriers/canada_post_pws_rating_test.rb +66 -59
  55. data/test/unit/carriers/canada_post_pws_shipping_test.rb +34 -23
  56. data/test/unit/carriers/correios_test.rb +244 -0
  57. data/test/unit/carriers/fedex_test.rb +161 -156
  58. data/test/unit/carriers/ups_test.rb +193 -1
  59. data/test/unit/carriers/usps_test.rb +14 -0
  60. data/test/unit/location_test.rb +0 -10
  61. metadata +63 -46
  62. metadata.gz.sig +0 -0
  63. data/lib/vendor/test_helper.rb +0 -6
  64. data/lib/vendor/xml_node/README +0 -36
  65. data/lib/vendor/xml_node/Rakefile +0 -21
  66. data/lib/vendor/xml_node/benchmark/bench_generation.rb +0 -30
  67. data/lib/vendor/xml_node/init.rb +0 -1
  68. data/lib/vendor/xml_node/lib/xml_node.rb +0 -221
  69. data/lib/vendor/xml_node/test/test_generating.rb +0 -89
  70. data/lib/vendor/xml_node/test/test_parsing.rb +0 -40
  71. data/test/fixtures/xml/fedex/tracking_response.xml +0 -151
  72. data/test/fixtures/xml/fedex/tracking_response_empty_destination.xml +0 -76
  73. data/test/fixtures/xml/fedex/tracking_response_no_destination.xml +0 -139
  74. data/test/fixtures/xml/fedex/tracking_response_no_ship_time.xml +0 -150
  75. data/test/fixtures/xml/fedex/tracking_response_with_estimated_delivery_date.xml +0 -95
  76. data/test/fixtures/xml/fedex/tracking_response_with_shipper_address.xml +0 -71
@@ -2,6 +2,7 @@ require 'test_helper'
2
2
 
3
3
  class RemoteStampsTest < Minitest::Test
4
4
  include ActiveShipping::Test::Credentials
5
+ include ActiveShipping::Test::Fixtures
5
6
 
6
7
  def setup
7
8
  @carrier = Stamps.new(credentials(:stamps).merge(test: true))
@@ -52,8 +52,6 @@ class RemoteUPSTest < Minitest::Test
52
52
  end
53
53
 
54
54
  def test_just_country_given
55
- skip if @options[:origin_account]
56
-
57
55
  response = @carrier.find_rates(
58
56
  location_fixtures[:beverly_hills],
59
57
  Location.new(:country => 'CA'),
@@ -63,17 +61,6 @@ class RemoteUPSTest < Minitest::Test
63
61
  refute response.rates.empty?
64
62
  end
65
63
 
66
- def test_just_country_given_with_origin_account_fails
67
- skip unless @options[:origin_account]
68
- assert_raises(ResponseError) do
69
- @carrier.find_rates(
70
- location_fixtures[:beverly_hills],
71
- Location.new(:country => 'CA'),
72
- Package.new(100, [5, 10, 20])
73
- )
74
- end
75
- end
76
-
77
64
  def test_ottawa_to_beverly_hills
78
65
  response = @carrier.find_rates(
79
66
  location_fixtures[:ottawa],
@@ -109,19 +96,6 @@ class RemoteUPSTest < Minitest::Test
109
96
  assert_nil package_rate[:rate]
110
97
  end
111
98
 
112
- def test_ottawa_to_us_fails_with_only_zip_and_origin_account
113
- skip unless @options[:origin_account]
114
-
115
- assert_raises ResponseError do
116
- @carrier.find_rates(
117
- location_fixtures[:ottawa],
118
- Location.new(:country => 'US', :zip => 90210),
119
- package_fixtures.values_at(:book, :wii),
120
- :test => true
121
- )
122
- end
123
- end
124
-
125
99
  def test_ottawa_to_us_fails_without_zip
126
100
  assert_raises(ResponseError) do
127
101
  response = @carrier.find_rates(
@@ -134,8 +108,6 @@ class RemoteUPSTest < Minitest::Test
134
108
  end
135
109
 
136
110
  def test_ottawa_to_us_succeeds_with_only_zip
137
- skip if @options[:origin_account]
138
-
139
111
  response = @carrier.find_rates(
140
112
  location_fixtures[:ottawa],
141
113
  Location.new(:country => 'US', :zip => 90210),
@@ -212,19 +184,10 @@ class RemoteUPSTest < Minitest::Test
212
184
  end
213
185
 
214
186
  def test_obtain_shipping_label
215
- skip '<#<RuntimeError: Could not obtain shipping label. Invalid Access License number.>>.'
216
-
217
- # I want to provide some helpful information if this test fails.
218
- # Perhaps it is better to skip and warn than to make an *assertion*
219
- # about configuration?
220
- assert @options[:origin_name].present?, "test/fixtures.yml must have a valid ups/origin_name for this test to run"
221
- assert @options[:origin_account].present?, "test/fixtures.yml must have a valid ups/origin_account for this test to run"
222
-
223
-
224
187
  response = @carrier.create_shipment(
225
188
  location_fixtures[:beverly_hills],
226
189
  location_fixtures[:new_york_with_name],
227
- package_fixtures.values_at(:chocolate_stuff, :book, :american_wii),
190
+ package_fixtures.values_at(:chocolate_stuff, :small_half_pound, :american_wii),
228
191
  :test => true,
229
192
  :reference_number => { :value => "FOO-123", :code => "PO" }
230
193
  )
@@ -239,8 +202,6 @@ class RemoteUPSTest < Minitest::Test
239
202
  end
240
203
 
241
204
  def test_obtain_shipping_label_without_dimensions
242
- skip '<#<RuntimeError: Could not obtain shipping label. Invalid Access License number.>>.'
243
-
244
205
  response = @carrier.create_shipment(
245
206
  location_fixtures[:beverly_hills],
246
207
  location_fixtures[:new_york_with_name],
@@ -256,4 +217,80 @@ class RemoteUPSTest < Minitest::Test
256
217
  # ought to raise an exception and this test will fail.
257
218
  assert_instance_of ActiveShipping::LabelResponse, response
258
219
  end
220
+
221
+ def test_obtain_international_shipping_label
222
+ response = @carrier.create_shipment(
223
+ location_fixtures[:new_york_with_name],
224
+ location_fixtures[:ottawa_with_name],
225
+ package_fixtures.values_at(:books),
226
+ {
227
+ :service_code => '07',
228
+ :test => true,
229
+ }
230
+ )
231
+
232
+ assert response.success?
233
+
234
+ # All behavior specific to how a LabelResponse behaves in the
235
+ # context of UPS label data is a matter for unit tests. If
236
+ # the data changes substantially, the create_shipment
237
+ # ought to raise an exception and this test will fail.
238
+ assert_instance_of ActiveShipping::LabelResponse, response
239
+ end
240
+
241
+ def test_delivery_date_estimates_within_zip
242
+ today = Date.current
243
+
244
+ response = @carrier.get_delivery_date_estimates(
245
+ location_fixtures[:new_york_with_name],
246
+ location_fixtures[:new_york_with_name],
247
+ package_fixtures.values_at(:books),
248
+ today,
249
+ {
250
+ :test => true
251
+ }
252
+ )
253
+
254
+ assert response.success?
255
+ refute_empty response.delivery_estimates
256
+ ground_delivery_estimate = response.delivery_estimates.select {|de| de.service_name == "UPS Ground"}.first
257
+ assert_equal Date.parse(1.business_days.from_now.to_s), ground_delivery_estimate.date
258
+ end
259
+
260
+ def test_delivery_date_estimates_across_zips
261
+ today = Date.current
262
+
263
+ response = @carrier.get_delivery_date_estimates(
264
+ location_fixtures[:new_york_with_name],
265
+ location_fixtures[:real_home_as_residential],
266
+ package_fixtures.values_at(:books),
267
+ today,
268
+ {
269
+ :test => true
270
+ }
271
+ )
272
+
273
+ assert response.success?
274
+ refute_empty response.delivery_estimates
275
+ ground_delivery_estimate = response.delivery_estimates.select {|de| de.service_name == "UPS Ground"}.first
276
+ assert_equal Date.parse(3.business_days.from_now.to_s), ground_delivery_estimate.date
277
+ next_day_delivery_estimate = response.delivery_estimates.select {|de| de.service_name == "UPS Next Day Air"}.first
278
+ assert_equal Date.parse(1.business_days.from_now.to_s), next_day_delivery_estimate.date
279
+ end
280
+
281
+ def test_rate_with_single_service
282
+ response = @carrier.find_rates(
283
+ location_fixtures[:new_york_with_name],
284
+ location_fixtures[:real_home_as_residential],
285
+ package_fixtures.values_at(:books),
286
+ {
287
+ :service => UPS::DEFAULT_SERVICE_NAME_TO_CODE["UPS Ground"],
288
+ :test => true
289
+ }
290
+ )
291
+
292
+ assert response.success?
293
+ refute response.rates.empty?
294
+ assert_equal ["UPS Ground"], response.rates.map(&:service_name)
295
+ end
259
296
  end
@@ -201,10 +201,22 @@ class RemoteUSPSTest < Minitest::Test
201
201
  end
202
202
  end
203
203
 
204
- def test_valid_credentials
204
+ def test_correct_login_passes_valid_credentials?
205
205
  assert USPS.new(@usps_credentials.merge(:test => true)).valid_credentials?
206
206
  end
207
207
 
208
+ def test_wrong_login_fails_in_valid_credentials?
209
+ refute USPS.new(:login => 'ABCDEFGHIJKL', :test => true).valid_credentials?
210
+ end
211
+
212
+ def test_blank_login_fails_in_valid_credentials?
213
+ refute USPS.new(:login => '', :test => true).valid_credentials?
214
+ end
215
+
216
+ def test_nil_login_fails_in_valid_credentials?
217
+ refute USPS.new(:login => nil, :test => true).valid_credentials?
218
+ end
219
+
208
220
  def test_must_provide_login_creds_when_instantiating
209
221
  assert_raises ArgumentError do
210
222
  USPS.new(:test => true)
data/test/test_helper.rb CHANGED
@@ -3,6 +3,7 @@ require 'bundler/setup'
3
3
  require 'minitest/autorun'
4
4
  require 'mocha/mini_test'
5
5
  require 'timecop'
6
+ require 'business_time'
6
7
 
7
8
  require 'active_shipping'
8
9
  require 'logger'
@@ -32,7 +33,7 @@ module ActiveShipping::Test
32
33
 
33
34
  def credentials(key)
34
35
  data = all_credentials[key]
35
- if data.nil? || data.all? { |k,v| v.nil? || v.empty? }
36
+ if data.nil? || data.all? { |k,v| v.nil? || v.to_s.empty? }
36
37
  raise NoCredentialsFound.new(key)
37
38
  end
38
39
  data.symbolize_keys
@@ -87,7 +88,8 @@ module ActiveShipping::Test
87
88
  :declared_value => Package.new(80, [2, 6, 12], :units => :imperial, :currency => 'USD', :value => 999.99),
88
89
  :tshirts => Package.new(10 * 16, nil, :units => :imperial),
89
90
  :shipping_container => Package.new(2200000, [2440, 2600, 6058], :description => '20 ft Standard Container', :units => :metric),
90
- :largest_gold_bar => Package.new(250000, [45.5, 22.5, 17], :value => 15300000)
91
+ :largest_gold_bar => Package.new(250000, [45.5, 22.5, 17], :value => 15300000),
92
+ :books => Package.new(64, [4, 8, 6], :units => :imperial, :value => 15300000, :description => 'Books')
91
93
  }
92
94
  end
93
95
 
@@ -102,6 +104,14 @@ module ActiveShipping::Test
102
104
  :postal_code => 'K1P 1J1',
103
105
  :phone => '1-613-580-2400',
104
106
  :fax => '1-613-580-2495'),
107
+ :ottawa_with_name => Location.new( :country => 'CA',
108
+ :province => 'ON',
109
+ :city => 'Ottawa',
110
+ :name => 'Paul Ottawa',
111
+ :address1 => '110 Laurier Avenue West',
112
+ :postal_code => 'K1P 1J1',
113
+ :phone => '1-613-580-2400',
114
+ :fax => '1-613-580-2495'),
105
115
  :beverly_hills => Location.new(
106
116
  :country => 'US',
107
117
  :state => 'CA',
@@ -112,46 +112,50 @@ class CanadaPostPwsRatingTest < Minitest::Test
112
112
 
113
113
  def test_build_rates_request
114
114
  xml = @cp.build_rates_request(@home_params, @dest_params, [@pkg1, @pkg2], @default_options)
115
- doc = Nokogiri::HTML(xml)
115
+ doc = Nokogiri.XML(xml)
116
+ doc.remove_namespaces!
116
117
 
117
- assert_equal @default_options[:customer_number], doc.xpath('//customer-number').first.content
118
- assert_equal 'K1P1J1', doc.xpath('//origin-postal-code').first.content
119
- assert_equal 'united-states', doc.xpath('//destination').children.first.name
118
+ assert_equal @default_options[:customer_number], doc.at('//customer-number').text
119
+ assert_equal 'K1P1J1', doc.at('//origin-postal-code').text
120
+ assert_equal 'united-states', doc.at('//destination/*').name
120
121
  assert !doc.xpath('//parcel-characteristics').empty?
121
- assert_equal "3.427", doc.xpath('//parcel-characteristics//weight').first.content
122
+ assert_equal "3.427", doc.at('//parcel-characteristics//weight').text
122
123
  end
123
124
 
124
125
  def test_build_rates_request_use_carrier_customer_number
125
126
  xml = @cp_customer_number.build_rates_request(@home_params, @dest_params, [@pkg1, @pkg2])
126
- doc = Nokogiri::HTML(xml)
127
+ doc = Nokogiri.XML(xml)
128
+ doc.remove_namespaces!
127
129
 
128
- assert_equal @customer_number, doc.xpath('//customer-number').first.content
129
- assert_equal 'K1P1J1', doc.xpath('//origin-postal-code').first.content
130
- assert_equal 'united-states', doc.xpath('//destination').children.first.name
130
+ assert_equal @customer_number, doc.at('//customer-number').text
131
+ assert_equal 'K1P1J1', doc.at('//origin-postal-code').text
132
+ assert_equal 'united-states', doc.at('//destination/*').name
131
133
  assert !doc.xpath('//parcel-characteristics').empty?
132
- assert_equal "3.427", doc.xpath('//parcel-characteristics//weight').first.content
134
+ assert_equal "3.427", doc.at('//parcel-characteristics//weight').text
133
135
  end
134
136
 
135
137
  def test_build_rates_request_override_carrier_customer_number
136
138
  xml = @cp_customer_number.build_rates_request(@home_params, @dest_params, [@pkg1, @pkg2], @default_options)
137
- doc = Nokogiri::HTML(xml)
138
-
139
- assert_equal @default_options[:customer_number], doc.xpath('//customer-number').first.content
140
- assert_equal 'K1P1J1', doc.xpath('//origin-postal-code').first.content
141
- assert_equal 'united-states', doc.xpath('//destination').children.first.name
142
- assert !doc.xpath('//parcel-characteristics').empty?
143
- assert_equal "3.427", doc.xpath('//parcel-characteristics//weight').first.content
139
+ doc = Nokogiri.XML(xml)
140
+ doc.remove_namespaces!
141
+
142
+ assert_equal @default_options[:customer_number], doc.at('//customer-number').text
143
+ assert_equal 'K1P1J1', doc.at('//origin-postal-code').text
144
+ assert_equal 'united-states', doc.at('//destination/*').name
145
+ assert doc.at('//parcel-characteristics')
146
+ assert_equal "3.427", doc.at('//parcel-characteristics//weight').text
144
147
  end
145
148
 
146
149
  def test_build_rates_request_location_object
147
150
  xml = @cp.build_rates_request(Location.new(@home_params), Location.new(@dest_params), [@pkg1, @pkg2], @default_options)
148
- doc = Nokogiri::HTML(xml)
151
+ doc = Nokogiri.XML(xml)
152
+ doc.remove_namespaces!
149
153
 
150
- assert_equal @default_options[:customer_number], doc.xpath('//customer-number').first.content
151
- assert_equal 'K1P1J1', doc.xpath('//origin-postal-code').first.content
152
- assert_equal 'united-states', doc.xpath('//destination').children.first.name
154
+ assert_equal @default_options[:customer_number], doc.at('//customer-number').text
155
+ assert_equal 'K1P1J1', doc.at('//origin-postal-code').text
156
+ assert_equal 'united-states', doc.at('//destination/*').name
153
157
  assert !doc.xpath('//parcel-characteristics').empty?
154
- assert_equal "3.427", doc.xpath('//parcel-characteristics//weight').first.content
158
+ assert_equal "3.427", doc.at('//parcel-characteristics//weight').text
155
159
  end
156
160
 
157
161
  def test_build_rates_request_domestic
@@ -166,11 +170,12 @@ class CanadaPostPwsRatingTest < Minitest::Test
166
170
  :postal_code => 'V5J 1J1'
167
171
  }
168
172
  xml = @cp.build_rates_request(@home_params, @dest_params, [@pkg1, @pkg2], @default_options)
169
- doc = Nokogiri::HTML(xml)
173
+ doc = Nokogiri.XML(xml)
174
+ doc.remove_namespaces!
170
175
 
171
- assert_equal 'K1P1J1', doc.xpath('//origin-postal-code').first.content
172
- assert_equal 'domestic', doc.xpath('//destination').children.first.name
173
- assert_equal 'V5J1J1', doc.xpath('//destination//postal-code').first.content
176
+ assert_equal 'K1P1J1', doc.at('//origin-postal-code').text
177
+ assert_equal 'domestic', doc.at('//destination/*').name
178
+ assert_equal 'V5J1J1', doc.at('//destination//postal-code').text
174
179
  end
175
180
 
176
181
  def test_build_rates_request_international
@@ -183,89 +188,91 @@ class CanadaPostPwsRatingTest < Minitest::Test
183
188
  :country => 'JP'
184
189
  }
185
190
  xml = @cp.build_rates_request(@home_params, @dest_params, [@pkg1, @pkg2], @default_options)
186
- doc = Nokogiri::HTML(xml)
191
+ doc = Nokogiri.XML(xml)
192
+ doc.remove_namespaces!
187
193
 
188
- assert_equal 'K1P1J1', doc.xpath('//origin-postal-code').first.content
189
- assert_equal 'international', doc.xpath('//destination').children.first.name
190
- assert_equal 'JP', doc.xpath('//destination//country-code').first.content
194
+ assert_equal 'K1P1J1', doc.xpath('//origin-postal-code').text
195
+ assert_equal 'international', doc.at('//destination/*').name
196
+ assert_equal 'JP', doc.at('//destination//country-code').text
191
197
  end
192
198
 
193
199
  def test_build_rates_request_with_cod_option
194
200
  opts = @default_options.merge(:cod => true, :cod_amount => 12.05)
195
201
  xml = @cp.build_rates_request(@home_params, @dest_params, [@pkg1, @pkg2], opts)
196
- doc = Nokogiri::HTML(xml)
197
-
198
- assert_equal 'COD', doc.xpath('//options/option').children.first.content
199
- assert_equal '12.05', doc.xpath('//options/option').children.last.content
202
+ doc = Nokogiri.XML(xml)
203
+ doc.remove_namespaces!
204
+ assert_equal 'COD', doc.xpath('//options/option/option-code').text
205
+ assert_equal '12.05', doc.xpath('//options/option/option-amount').text
200
206
  end
201
207
 
202
208
  def test_build_rates_request_with_signature_option
203
209
  opts = @default_options.merge(:so => true)
204
210
  xml = @cp.build_rates_request(@home_params, @dest_params, [@pkg1, @pkg2], opts)
205
- doc = Nokogiri::HTML(xml)
206
-
207
- assert_equal 'SO', doc.xpath('//options/option').children.first.content
211
+ doc = Nokogiri.XML(xml)
212
+ doc.remove_namespaces!
213
+ assert_equal 'SO', doc.at('//options/option/option-code').text
208
214
  end
209
215
 
210
216
  def test_build_rates_request_with_insurance_option
211
217
  opts = @default_options.merge(:cov => true, :cov_amount => 122.05)
212
218
  xml = @cp.build_rates_request(@home_params, @dest_params, [@pkg1, @pkg2], opts)
213
- doc = Nokogiri::HTML(xml)
214
-
215
- assert_equal 'COV', doc.xpath('//options/option').children.first.content
216
- assert_equal '122.05', doc.xpath('//options/option').children.last.content
219
+ doc = Nokogiri.XML(xml)
220
+ doc.remove_namespaces!
221
+ assert_equal 'COV', doc.at('//options/option/option-code').text
222
+ assert_equal '122.05', doc.at('//options/option/option-amount').text
217
223
  end
218
224
 
219
225
  def test_build_rates_request_with_other_options
220
226
  opts = @default_options.merge(:pa18 => true, :pa19 => true, :hfp => true, :dns => true, :lad => true)
221
227
  xml = @cp.build_rates_request(@home_params, @dest_params, [@pkg1, @pkg2], opts)
222
- doc = Nokogiri::HTML(xml)
223
-
224
- options = doc.xpath('//options/option').map(&:content).sort
228
+ doc = Nokogiri.XML(xml)
229
+ doc.remove_namespaces!
230
+ options = doc.xpath('//options/option/option-code').map(&:text).sort
225
231
  assert_equal %w(PA18 PA19 HFP DNS LAD).sort, options
226
232
  end
227
233
 
228
234
  def test_build_rates_request_with_single_item
229
235
  opts = @default_options
230
236
  xml = @cp.build_rates_request(@home_params, @dest_params, [@pkg1], opts)
231
- doc = Nokogiri::HTML(xml)
232
-
233
- assert_equal '0.025', doc.xpath('//parcel-characteristics/weight').first.content
237
+ doc = Nokogiri.XML(xml)
238
+ doc.remove_namespaces!
239
+ assert_equal '0.025', doc.at('//parcel-characteristics/weight').text
234
240
  end
235
241
 
236
242
  def test_build_rates_request_with_mailing_tube
237
243
  pkg = Package.new(25, [93, 10], :cylinder => true)
238
244
  opts = @default_options
239
245
  xml = @cp.build_rates_request(@home_params, @dest_params, [pkg], opts)
240
- doc = Nokogiri::HTML(xml)
241
-
242
- assert_equal 'true', doc.xpath('//parcel-characteristics/mailing-tube').first.content
246
+ doc = Nokogiri.XML(xml)
247
+ doc.remove_namespaces!
248
+ assert_equal 'true', doc.at('//parcel-characteristics/mailing-tube').text
243
249
  end
244
250
 
245
251
  def test_build_rates_request_with_oversize
246
252
  pkg = Package.new(25, [93, 10], :oversized => true)
247
253
  opts = @default_options
248
254
  xml = @cp.build_rates_request(@home_params, @dest_params, [pkg], opts)
249
- doc = Nokogiri::HTML(xml)
250
-
251
- assert_equal 'true', doc.xpath('//parcel-characteristics/oversized').first.content
255
+ doc = Nokogiri.XML(xml)
256
+ doc.remove_namespaces!
257
+ assert_equal 'true', doc.at('//parcel-characteristics/oversized').text
252
258
  end
253
259
 
254
260
  def test_build_rates_request_with_unpackaged
255
261
  pkg = Package.new(25, [93, 10], :unpackaged => true)
256
262
  opts = @default_options
257
263
  xml = @cp.build_rates_request(@home_params, @dest_params, [pkg], opts)
258
- doc = Nokogiri::HTML(xml)
259
-
260
- assert_equal 'true', doc.xpath('//parcel-characteristics/unpackaged').first.content
264
+ doc = Nokogiri.XML(xml)
265
+ doc.remove_namespaces!
266
+ assert_equal 'true', doc.at('//parcel-characteristics/unpackaged').text
261
267
  end
262
268
 
263
269
  def test_build_rates_request_with_zero_weight
264
270
  options = @default_options.merge(@shipping_opts1)
265
271
  line_items = [Package.new(0, [93, 10]), Package.new(0, [10, 10])]
266
- request = @cp.build_rates_request(@home_params, @dest_params, line_items, options)
267
- doc = Nokogiri::HTML(request)
268
- assert_equal '0.001', doc.xpath('//parcel-characteristics/weight').first.content
272
+ xml = @cp.build_rates_request(@home_params, @dest_params, line_items, options)
273
+ doc = Nokogiri.XML(xml)
274
+ doc.remove_namespaces!
275
+ assert_equal '0.001', doc.at('//parcel-characteristics/weight').text
269
276
  end
270
277
 
271
278
  # parse response