active_shipping 1.14.2 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (77) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +3 -25
  3. data/CHANGELOG.md +5 -0
  4. data/CONTRIBUTING.md +2 -0
  5. data/README.md +2 -8
  6. data/active_shipping.gemspec +9 -3
  7. data/gemfiles/activesupport42.gemfile +0 -1
  8. data/lib/active_shipping.rb +1 -1
  9. data/lib/active_shipping/carrier.rb +2 -4
  10. data/lib/active_shipping/carriers/australia_post.rb +2 -4
  11. data/lib/active_shipping/carriers/canada_post.rb +1 -1
  12. data/lib/active_shipping/carriers/canada_post_pws.rb +33 -37
  13. data/lib/active_shipping/carriers/correios.rb +0 -2
  14. data/lib/active_shipping/carriers/new_zealand_post.rb +0 -2
  15. data/lib/active_shipping/carriers/ups.rb +0 -2
  16. data/lib/active_shipping/carriers/usps.rb +1 -3
  17. data/lib/active_shipping/external_return_label_request.rb +0 -4
  18. data/lib/active_shipping/location.rb +65 -52
  19. data/lib/active_shipping/package.rb +17 -21
  20. data/lib/active_shipping/package_item.rb +8 -20
  21. data/lib/active_shipping/rate_estimate.rb +1 -1
  22. data/lib/active_shipping/version.rb +1 -1
  23. data/test/fixtures/xml/canadapost/example_request.xml +3 -3
  24. data/test/helpers/holiday_helpers.rb +54 -0
  25. data/test/remote/australia_post_test.rb +1 -1
  26. data/test/remote/canada_post_pws_platform_test.rb +1 -3
  27. data/test/remote/canada_post_pws_test.rb +1 -1
  28. data/test/remote/canada_post_test.rb +1 -1
  29. data/test/remote/correios_test.rb +1 -2
  30. data/test/remote/fedex_test.rb +8 -8
  31. data/test/remote/kunaki_test.rb +1 -1
  32. data/test/remote/new_zealand_post_test.rb +1 -1
  33. data/test/remote/shipwire_test.rb +1 -1
  34. data/test/remote/stamps_test.rb +7 -7
  35. data/test/remote/ups_surepost_test.rb +1 -1
  36. data/test/remote/ups_test.rb +13 -11
  37. data/test/remote/usps_returns_test.rb +1 -1
  38. data/test/remote/usps_test.rb +5 -5
  39. data/test/test_helper.rb +16 -6
  40. data/test/unit/carrier_test.rb +25 -25
  41. data/test/unit/carriers/australia_post_test.rb +5 -5
  42. data/test/unit/carriers/benchmark_test.rb +1 -1
  43. data/test/unit/carriers/canada_post_pws_rating_test.rb +1 -15
  44. data/test/unit/carriers/canada_post_pws_register_test.rb +1 -15
  45. data/test/unit/carriers/canada_post_pws_shipping_test.rb +1 -13
  46. data/test/unit/carriers/canada_post_pws_test.rb +4 -4
  47. data/test/unit/carriers/canada_post_pws_tracking_test.rb +1 -1
  48. data/test/unit/carriers/canada_post_test.rb +9 -9
  49. data/test/unit/carriers/correios_test.rb +1 -2
  50. data/test/unit/carriers/fedex_test.rb +5 -5
  51. data/test/unit/carriers/kunaki_test.rb +1 -1
  52. data/test/unit/carriers/new_zealand_post_test.rb +9 -10
  53. data/test/unit/carriers/shipwire_test.rb +1 -1
  54. data/test/unit/carriers/stamps_test.rb +1 -1
  55. data/test/unit/carriers/ups_test.rb +1 -1
  56. data/test/unit/carriers/usps_returns_test.rb +1 -1
  57. data/test/unit/carriers/usps_test.rb +1 -1
  58. data/test/unit/carriers_test.rb +4 -5
  59. data/test/unit/external_return_label_request_test.rb +129 -83
  60. data/test/unit/location_test.rb +187 -91
  61. data/test/unit/package_item_test.rb +42 -47
  62. data/test/unit/package_test.rb +76 -75
  63. data/test/unit/rate_estimate_test.rb +16 -20
  64. data/test/unit/response_test.rb +28 -9
  65. data/test/unit/shipment_event_test.rb +1 -1
  66. data/test/unit/shipment_packer_test.rb +31 -31
  67. data/test/unit/tracking_response_test.rb +1 -1
  68. metadata +71 -23
  69. data/gemfiles/activesupport32.gemfile +0 -7
  70. data/gemfiles/activesupport32_nokogiri_17.gemfile +0 -7
  71. data/gemfiles/activesupport40.gemfile +0 -6
  72. data/gemfiles/activesupport40_nokogiri_17.gemfile +0 -6
  73. data/gemfiles/activesupport41.gemfile +0 -6
  74. data/gemfiles/activesupport41_nokogiri_17.gemfile +0 -6
  75. data/gemfiles/activesupport42_nokogiri_17.gemfile +0 -6
  76. data/test/fixtures/xml/canadapost_pws/merchant_details_response_no_contract_number.xml +0 -7
  77. data/test/fixtures/xml/canadapost_pws/service_options_response_priority_worldwide.xml +0 -41
@@ -1,135 +1,231 @@
1
1
  require 'test_helper'
2
2
 
3
- class LocationTest < Minitest::Test
3
+ class LocationTest < ActiveSupport::TestCase
4
4
  include ActiveShipping::Test::Fixtures
5
5
 
6
- def test_countries
7
- assert_instance_of ActiveUtils::Country, location_fixtures[:ottawa].country
8
- assert_equal 'CA', location_fixtures[:ottawa].country_code(:alpha2)
9
- end
10
-
11
- def test_location_from_strange_hash
12
- hash = { :country => 'CA',
13
- :zip => '90210',
14
- :territory_code => 'QC',
15
- :town => 'Perth',
16
- :address => '66 Gregory Ave.',
17
- :phone => '515-555-1212',
18
- :fax_number => 'none to speak of',
19
- :address_type => :commercial
20
- }
21
- location = Location.from(hash)
22
-
23
- assert_equal hash[:country], location.country_code(:alpha2)
24
- assert_equal hash[:zip], location.zip
25
- assert_equal hash[:territory_code], location.province
26
- assert_equal hash[:town], location.city
27
- assert_equal hash[:address], location.address1
28
- assert_equal hash[:phone], location.phone
29
- assert_equal hash[:fax_number], location.fax
30
- assert_equal hash[:address_type].to_s, location.address_type
31
- end
32
-
33
- def test_pretty_print
34
- expected = "110 Laurier Avenue West\nOttawa, ON, K1P 1J1\nCanada"
35
- assert_equal expected, location_fixtures[:ottawa].prettyprint
6
+ setup do
7
+ @location = location_fixtures[:ottawa]
8
+ @address2 = 'Apt 613'
9
+ @address3 = 'Victory Lane'
10
+ @attributes_hash = {
11
+ country: 'CA',
12
+ zip: '90210',
13
+ territory_code: 'QC',
14
+ town: 'Perth',
15
+ address: '66 Gregory Ave.',
16
+ phone: '515-555-1212',
17
+ fax_number: 'none to speak of',
18
+ address_type: :commercial,
19
+ name: "Bob Bobsen",
20
+ }
21
+ end
22
+
23
+ test "#initialize sets a country object" do
24
+ assert_instance_of ActiveUtils::Country, @location.country
25
+ assert_equal 'CA', @location.country_code(:alpha2)
26
+ end
27
+
28
+ test ".from sets up the location from a hash" do
29
+ location = Location.from(@attributes_hash)
30
+
31
+ assert_equal @attributes_hash[:country], location.country_code(:alpha2)
32
+ assert_equal @attributes_hash[:zip], location.zip
33
+ assert_equal @attributes_hash[:territory_code], location.province
34
+ assert_equal @attributes_hash[:town], location.city
35
+ assert_equal @attributes_hash[:address], location.address1
36
+ assert_equal @attributes_hash[:phone], location.phone
37
+ assert_equal @attributes_hash[:fax_number], location.fax
38
+ assert_equal @attributes_hash[:address_type].to_s, location.address_type
39
+ assert_equal @attributes_hash[:name], location.name
40
+ end
41
+
42
+ test ".from sets from an object with properties" do
43
+ object = Class.new do
44
+ def initialize(hash)
45
+ @hash = hash
46
+ end
47
+ def method_missing(method)
48
+ @hash[method]
49
+ end
50
+ def respond_to?(method)
51
+ return false if method == :[]
52
+ true
53
+ end
54
+ end.new(@attributes_hash)
55
+
56
+ location = Location.from(object)
57
+
58
+ assert_equal @attributes_hash[:country], location.country_code(:alpha2)
59
+ assert_equal @attributes_hash[:zip], location.zip
60
+ assert_equal @attributes_hash[:territory_code], location.province
61
+ assert_equal @attributes_hash[:town], location.city
62
+ assert_equal @attributes_hash[:address], location.address1
63
+ assert_equal @attributes_hash[:phone], location.phone
64
+ assert_equal @attributes_hash[:fax_number], location.fax
65
+ assert_equal @attributes_hash[:address_type].to_s, location.address_type
66
+ assert_equal @attributes_hash[:name], location.name
67
+ end
68
+
69
+ test ".from adheres to propery order even if hash access is available" do
70
+ object = Class.new do
71
+ def [](index)
72
+ { province: "California" }[index]
73
+ end
74
+
75
+ def province_code
76
+ "CA"
77
+ end
78
+ end.new
79
+ assert_equal "CA", Location.from(object).province
80
+ end
81
+
82
+ test ".from sets the name to nil if it is not provided" do
83
+ location = Location.from({})
84
+ assert_nil location.name
36
85
  end
37
86
 
38
- def test_to_s
39
- expected = "110 Laurier Avenue West Ottawa, ON, K1P 1J1 Canada"
40
- assert_equal expected, location_fixtures[:ottawa].to_s
87
+ test ".from sets company and company_name from company" do
88
+ location = Location.from(company: "Mine")
89
+
90
+ assert_equal "Mine", location.company
91
+ assert_equal "Mine", location.company_name
41
92
  end
42
93
 
43
- def test_inspect
44
- expected = "110 Laurier Avenue West\nOttawa, ON, K1P 1J1\nCanada\nPhone: 1-613-580-2400\nFax: 1-613-580-2495"
45
- assert_equal expected, location_fixtures[:ottawa].inspect
94
+ test ".from sets company and company_name from company_name" do
95
+ location = Location.from(company_name: "Mine")
96
+
97
+ assert_equal "Mine", location.company
98
+ assert_equal "Mine", location.company_name
46
99
  end
47
100
 
48
- def test_includes_name
49
- location = Location.from(:name => "Bob Bobsen")
50
- assert_equal "Bob Bobsen", location.name
101
+ test ".from prioritizes company" do
102
+ location = Location.from(company_name: "from company_name", company: "from company")
103
+
104
+ assert_equal "from company", location.company
105
+ assert_equal "from company", location.company_name
51
106
  end
52
107
 
53
- def test_name_is_nil_if_not_provided
54
- location = Location.from({})
55
- assert_nil location.name
108
+ test "#prettyprint outputs a readable string" do
109
+ expected = "110 Laurier Avenue West\nOttawa, ON, K1P 1J1\nCanada"
110
+ assert_equal expected, @location.prettyprint
56
111
  end
57
112
 
58
- def test_location_with_company_name
59
- location = Location.from(:company => "Mine")
60
- assert_equal "Mine", location.company_name
113
+ test "#to_s outputs a readable string without newlines" do
114
+ expected = "110 Laurier Avenue West Ottawa, ON, K1P 1J1 Canada"
115
+ assert_equal expected, @location.to_s
116
+ end
61
117
 
62
- location = Location.from(:company_name => "Mine")
63
- assert_equal "Mine", location.company_name
118
+ test "#inspect returns a readable string" do
119
+ expected = "110 Laurier Avenue West\nOttawa, ON, K1P 1J1\nCanada\nPhone: 1-613-580-2400\nFax: 1-613-580-2495"
120
+ assert_equal expected, @location.inspect
64
121
  end
65
122
 
66
- def test_set_address_type
67
- location = location_fixtures[:ottawa]
68
- assert !location.commercial?
123
+ test "#address_type= assigns a type of address as commercial" do
124
+ refute @location.commercial?
69
125
 
70
- location.address_type = :commercial
71
- assert location.commercial?
126
+ @location.address_type = :commercial
127
+ assert @location.commercial?
128
+ refute @location.residential?
129
+ assert_equal "commercial", @location.address_type
72
130
  end
73
131
 
74
- def test_set_address_type_invalid
75
- location = location_fixtures[:ottawa]
132
+ test "#address_type= assigns a type of address as residential" do
133
+ refute @location.residential?
76
134
 
135
+ @location.address_type = :residential
136
+ assert @location.residential?
137
+ refute @location.commercial?
138
+ assert_equal "residential", @location.address_type
139
+ end
140
+
141
+ test "#address_type= raises on an invalid assignment" do
77
142
  assert_raises(ArgumentError) do
78
- location.address_type = :new_address_type
143
+ @location.address_type = :new_address_type
79
144
  end
80
145
 
81
- refute_equal "new_address_type", location.address_type
146
+ assert_nil @location.address_type
82
147
  end
83
148
 
84
- def test_to_hash_attributes
85
- assert_equal %w(address1 address2 address3 address_type city company_name country fax name phone postal_code province), location_fixtures[:ottawa].to_hash.stringify_keys.keys.sort
149
+ test "#address_type= cannot blank out the value as nil" do
150
+ @location.address_type = :residential
151
+ assert @location.residential?
152
+
153
+ @location.address_type = nil
154
+ assert @location.residential?
155
+ assert_equal "residential", @location.address_type
86
156
  end
87
157
 
88
- def test_to_json
89
- location_json = location_fixtures[:ottawa].to_json
90
- assert_equal location_fixtures[:ottawa].to_hash, JSON.parse(location_json).symbolize_keys
158
+ test "#address_type= cannot blank out the value as empty string" do
159
+ @location.address_type = :residential
160
+ assert @location.residential?
161
+
162
+ @location.address_type = ""
163
+ assert @location.residential?
164
+ assert_equal "residential", @location.address_type
91
165
  end
92
166
 
93
- def test_zip_plus_4_with_no_dash
94
- zip = "33333"
95
- plus_4 = "1234"
96
- zip_plus_4 = "#{zip}-#{plus_4}"
97
- location = Location.from(:zip => "#{zip}#{plus_4}")
98
- assert_equal zip_plus_4, location.zip_plus_4
167
+ test "#to_hash has the expected attributes" do
168
+ expected = %w(address1 address2 address3 address_type city company_name country fax name phone postal_code province)
169
+
170
+ assert_equal expected, @location.to_hash.stringify_keys.keys.sort
99
171
  end
100
172
 
101
- def test_zip_plus_4_with_dash
102
- zip = "33333"
103
- plus_4 = "1234"
104
- zip_plus_4 = "#{zip}-#{plus_4}"
105
- location = Location.from(:zip => zip_plus_4)
106
- assert_equal zip_plus_4, location.zip_plus_4
173
+ test "#to_json returns the JSON values" do
174
+ expected = JSON.parse(@location.to_json).symbolize_keys
175
+
176
+ assert_equal @location.to_hash, expected
107
177
  end
108
178
 
109
- def test_address2_and_3_is_nil
110
- location = location_fixtures[:ottawa]
111
- assert_nil location.address2
112
- assert_nil location.address3
113
- assert location.address2_and_3.blank?
179
+ test "#zip_plus_4 nil without the extra four" do
180
+ zip = "12345"
181
+ location = Location.from(zip: zip)
182
+
183
+ assert_nil location.zip_plus_4
184
+ assert_equal zip, location.zip
114
185
  end
115
186
 
116
- def test_address2_and_3
117
- address2 = 'Apt 613'
118
- address3 = 'Victory Lane'
119
- location = Location.from(:address2 => address2)
187
+ test "#zip_plus_4 parses without the dash" do
188
+ zip = "12345-9999"
189
+ zip_without_dash = "123459999"
190
+ location = Location.from(zip: zip_without_dash)
191
+
192
+ assert_equal zip, location.zip_plus_4
193
+ assert_equal zip_without_dash, location.zip
194
+ end
195
+
196
+ test "#zip_plus_4 parses with the dash" do
197
+ zip = "12345-9999"
198
+ location = Location.from(zip: zip)
199
+
200
+ assert_equal zip, location.zip_plus_4
201
+ assert_equal zip, location.zip
202
+ end
203
+
204
+ test "#address2_and_3 shows just address2" do
205
+ location = Location.from(address2: @address2)
120
206
  assert_equal 'Apt 613', location.address2_and_3
207
+ end
208
+
209
+ test "#address2_and_3 shows just address3" do
210
+ location = Location.from(address3: @address3)
211
+ assert_equal @address3, location.address2_and_3
212
+ end
121
213
 
122
- location = Location.from(:address2 => address2, :address3 => address3)
123
- assert_equal 'Apt 613, Victory Lane', location.address2_and_3
214
+ test "#address2_and_3 shows both address2 and address3" do
215
+ location = Location.from(address2: @address2, address3: @address3)
216
+ assert_equal "#{@address2}, #{@address3}", location.address2_and_3
217
+ end
124
218
 
125
- location = Location.from(:address3 => address3)
126
- assert_equal 'Victory Lane', location.address2_and_3
219
+ test "#address2_and_3 shows an empty string when address2 and address3 are both blank" do
220
+ assert_nil @location.address2
221
+ assert_nil @location.address3
222
+ assert_equal "", @location.address2_and_3
127
223
  end
128
224
 
129
- def test_equality
130
- location_1 = location_fixtures[:ottawa]
131
- location_2 = Location.from(location_1.to_hash)
225
+ test "#== compares locations by attributes" do
226
+ another_location = Location.from(@location.to_hash)
132
227
 
133
- assert_equal location_1, location_2
228
+ assert_equal @location, another_location
229
+ refute_equal @location, Location.new({})
134
230
  end
135
231
  end
@@ -1,7 +1,7 @@
1
1
  require 'test_helper'
2
2
 
3
- class PackageItemTest < Minitest::Test
4
- def setup
3
+ class PackageItemTest < ActiveSupport::TestCase
4
+ setup do
5
5
  @name = "Fancy Pants"
6
6
  @weight = 100
7
7
  @value = 1299
@@ -16,10 +16,10 @@ class PackageItemTest < Minitest::Test
16
16
  }
17
17
 
18
18
  @item = PackageItem.new(@name, @weight, @value, @quantity, @options)
19
- @mass = ::Quantified::Mass.new(@weight, :grams)
19
+ @mass = Measured::Weight.new(@weight, :grams)
20
20
  end
21
21
 
22
- def test_initialize_with_all_attributes
22
+ test "#initialize with all attributes" do
23
23
  assert_equal @name, @item.name
24
24
  assert_equal @options, @item.options
25
25
  assert_equal @hs_code, @item.hs_code
@@ -28,7 +28,7 @@ class PackageItemTest < Minitest::Test
28
28
  assert_equal @quantity, @item.quantity
29
29
  end
30
30
 
31
- def test_initialize_assumes_symbol_keys
31
+ test "#initialize assumes symbol keys" do
32
32
  options = {
33
33
  "units" => :imperial,
34
34
  "sku" => @sku,
@@ -42,98 +42,93 @@ class PackageItemTest < Minitest::Test
42
42
  assert_equal @weight, @item.grams
43
43
  end
44
44
 
45
- def test_initialize_negative_quantity
45
+ test "#initialize with a negative quantity" do
46
46
  assert_equal 1, PackageItem.new(@name, @weight, @value, -1).quantity
47
47
  assert_equal 1, PackageItem.new(@name, @weight, @value, 0).quantity
48
48
  end
49
49
 
50
- def test_initialize_weight_mass_object
51
- begin
52
- @item = PackageItem.new(@name, @mass, @value, @quantity, @options)
53
- assert_equal @mass, @item.weight
54
- flunk "This code path is broken but passed unexpectedly"
55
- rescue NameError
56
- skip "This code path is broken"
57
- end
50
+ test "#initialize weight mass object" do
51
+ @item = PackageItem.new(@name, @mass, @value, @quantity, @options)
52
+ assert_equal @mass, @item.weight
58
53
  end
59
54
 
60
- def test_initialize_weight_default_metric
55
+ test "#initialize weight default metric" do
61
56
  assert_equal @weight, @item.grams
62
57
  refute_equal @weight, @item.ounces
63
58
  end
64
59
 
65
- def test_initialize_weight_accepts_imperial
60
+ test "#initialize weight accepts imperial" do
66
61
  @item = PackageItem.new(@name, @weight, @value, @quantity, @options.merge(units: :imperial))
67
62
 
68
63
  assert_equal @weight, @item.ounces
69
64
  refute_equal @weight, @item.grams
70
65
  end
71
66
 
72
- def test_initialize_weight_accepts_metric
67
+ test "#initialize_weight accepts metric" do
73
68
  @item = PackageItem.new(@name, @weight, @value, @quantity, @options.merge(units: :metric))
74
69
 
75
70
  assert_equal @weight, @item.grams
76
71
  refute_equal @weight, @item.ounces
77
72
  end
78
73
 
79
- def test_initialize_weight_does_not_accept_strings
74
+ test "#initialize weight does not accept strings" do
80
75
  @item = PackageItem.new(@name, @weight, @value, @quantity, @options.merge(units: "imperial"))
81
76
 
82
77
  assert_equal @weight, @item.grams
83
78
  refute_equal @weight, @item.ounces
84
79
  end
85
80
 
86
- def test_initialize_value_from_cents
81
+ test "#initialize value from cents" do
87
82
  @item = PackageItem.new(@name, @weight, "1.23", @quantity, @options)
88
83
 
89
84
  assert_equal 123, @item.value
90
85
  end
91
86
 
92
- def test_weight
87
+ test "#weight default lookup" do
93
88
  assert_equal @mass, @item.weight
94
- assert_instance_of ::Quantified::Mass, @item.weight
89
+ assert_instance_of Measured::Weight, @item.weight
95
90
  end
96
91
 
97
- def test_weight_actual
92
+ test "#weight type: actual" do
98
93
  assert_equal @mass, @item.weight(type: :actual)
99
- assert_instance_of ::Quantified::Mass, @item.weight(type: :actual)
94
+ assert_instance_of Measured::Weight, @item.weight(type: :actual)
100
95
  end
101
96
 
102
- def test_weight_volumetric
97
+ test "#weight type: volumetric" do
103
98
  begin
104
99
  assert_equal :todo, @item.weight(type: :volumetric)
105
- assert_instance_of ::Quantified::Mass, @item.weight(type: :volumetric)
100
+ assert_instance_of Measured::Weight, @item.weight(type: :volumetric)
106
101
  flunk "This code path is broken but passed unexpectedly"
107
102
  rescue NoMethodError
108
103
  skip "This code path is broken"
109
104
  end
110
105
  end
111
106
 
112
- def test_weight_dimensional
107
+ test "#weight type: dimensional" do
113
108
  begin
114
109
  assert_equal :todo, @item.weight(type: :dimensional)
115
- assert_instance_of ::Quantified::Mass, @item.weight(type: :dimensional)
110
+ assert_instance_of Measured::Weight, @item.weight(type: :dimensional)
116
111
  flunk "This code path is broken but passed unexpectedly"
117
112
  rescue NoMethodError
118
113
  skip "This code path is broken"
119
114
  end
120
115
  end
121
116
 
122
- def test_weight_billable_max_weight_and_volumetric
117
+ test "#weight type: billable is the max of weight and volumetric" do
123
118
  begin
124
119
  assert_equal :todo, @item.weight(type: :billable)
125
- assert_instance_of ::Quantified::Mass, @item.weight(type: :billable)
120
+ assert_instance_of Measured::Weight, @item.weight(type: :billable)
126
121
  flunk "This code path is broken but passed unexpectedly"
127
122
  rescue NoMethodError
128
123
  skip "This code path is broken"
129
124
  end
130
125
  end
131
126
 
132
- def test_grams_value
127
+ test "#grams is the value" do
133
128
  assert_equal 100, @item.grams
134
129
  end
135
130
 
136
- def test_grams_accepts_options_with_type
131
+ test "#grams accepts options with type" do
137
132
  begin
138
133
  assert_equal :todo, @item.grams(type: :volumetric)
139
134
  flunk "This code path is broken but passed unexpectedly"
@@ -142,23 +137,23 @@ class PackageItemTest < Minitest::Test
142
137
  end
143
138
  end
144
139
 
145
- def test_grams_converts
140
+ test "#grams converts to another unit" do
146
141
  @item = PackageItem.new(@name, 100, @value, @quantity, @options.merge(units: :imperial))
147
142
 
148
143
  assert_in_delta 2834.9, @item.grams, 0.1
149
144
  end
150
145
 
151
- def test_grams_alias_g
146
+ test "#grams aliases to g" do
152
147
  assert_equal @item.grams, @item.g
153
148
  end
154
149
 
155
- def test_ounces_value
150
+ test "#ounces is the value" do
156
151
  @item = PackageItem.new(@name, @weight, @value, @quantity, @options.merge(units: :imperial))
157
152
 
158
153
  assert_equal 100, @item.ounces
159
154
  end
160
155
 
161
- def test_ounces_accepts_options_with_type
156
+ test "#ounces accepts options with type" do
162
157
  begin
163
158
  assert_equal :todo, @item.ounces(type: :volumetric)
164
159
  flunk "This code path is broken but passed unexpectedly"
@@ -167,23 +162,23 @@ class PackageItemTest < Minitest::Test
167
162
  end
168
163
  end
169
164
 
170
- def test_ounces_converts
165
+ test "#ounces converts to another unit" do
171
166
  @item = PackageItem.new(@name, @weight, @value, @quantity, @options.merge(units: :metric))
172
167
 
173
168
  assert_in_delta 3.5, @item.ounces, 0.1
174
169
  end
175
170
 
176
- def test_ounces_alias_oz
171
+ test "#ounces aliases to oz" do
177
172
  assert_equal @item.ounces, @item.oz
178
173
  end
179
174
 
180
- def test_pounds_value
175
+ test "#pounds is the value" do
181
176
  @item = PackageItem.new(@name, 32, @value, @quantity, @options.merge(units: :imperial))
182
177
 
183
178
  assert_equal 2, @item.pounds
184
179
  end
185
180
 
186
- def test_pounds_accepts_options_with_type
181
+ test "#pounds accepts options with type" do
187
182
  begin
188
183
  assert_equal :todo, @item.pounds(type: :volumetric)
189
184
  flunk "This code path is broken but passed unexpectedly"
@@ -192,27 +187,27 @@ class PackageItemTest < Minitest::Test
192
187
  end
193
188
  end
194
189
 
195
- def test_pounds_converts
190
+ test "#pounds converts to another unit" do
196
191
  @item = PackageItem.new(@name, 1000, @value, @quantity, @options.merge(units: :metric))
197
192
 
198
193
  assert_in_delta 2.2, @item.pounds, 0.1
199
194
  end
200
195
 
201
- def test_pounds_alias_lb
196
+ test "#pounds aliases to lb" do
202
197
  assert_equal @item.pounds, @item.lb
203
198
  end
204
199
 
205
- def test_pounds_alias_lbs
200
+ test "#pounds aliases to lbs" do
206
201
  assert_equal @item.pounds, @item.lbs
207
202
  end
208
203
 
209
- def test_kilograms_value
204
+ test "#kilograms is the value" do
210
205
  @item = PackageItem.new(@name, 1000, @value, @quantity, @options.merge(units: :metric))
211
206
 
212
207
  assert_equal 1, @item.kilograms
213
208
  end
214
209
 
215
- def test_kilograms_accepts_options_with_type
210
+ test "#kilograms accepts options with type" do
216
211
  begin
217
212
  assert_equal :todo, @item.kilograms(type: :volumetric)
218
213
  flunk "This code path is broken but passed unexpectedly"
@@ -221,17 +216,17 @@ class PackageItemTest < Minitest::Test
221
216
  end
222
217
  end
223
218
 
224
- def test_kilograms_converts
219
+ test "#kilograms converts to another unit" do
225
220
  @item = PackageItem.new(@name, 1000, @value, @quantity, @options.merge(units: :imperial))
226
221
 
227
222
  assert_in_delta 28.3, @item.kilograms, 0.1
228
223
  end
229
224
 
230
- def test_kilograms_alias_kg
225
+ test "#kilograms aliases to kg" do
231
226
  assert_equal @item.kilograms, @item.kg
232
227
  end
233
228
 
234
- def test_kilograms_alias_kgs
229
+ test "#kilograms aliases to kgs" do
235
230
  assert_equal @item.kilograms, @item.kgs
236
231
  end
237
232
  end