test/unit/carrier_test.rb in active_shipping-1.14.2 vs test/unit/carrier_test.rb in active_shipping-2.0.0
- old
+ new
@@ -1,116 +1,122 @@
require 'test_helper'
-class CarrierTest < Minitest::Test
+class CarrierTest < ActiveSupport::TestCase
class ExampleCarrier < Carrier
cattr_reader :name
@@name = "Example Carrier"
end
- def setup
+ setup do
@carrier = ExampleCarrier.new
end
- def test_find_rates_not_implemented
+ test "#find_rates is not implemented" do
assert_raises NotImplementedError do
@carrier.find_rates(nil, nil, nil)
end
end
- def test_create_shipment_not_implemented
+ test "#create_shipment is not implemented" do
assert_raises NotImplementedError do
@carrier.create_shipment(nil, nil, nil)
end
end
- def test_cancel_shipment_not_implemented
+ test "#cancel_shipment is not implemented" do
assert_raises NotImplementedError do
@carrier.cancel_shipment(nil)
end
end
- def test_find_tracking_info_not_implemented
+ test "#find_tracking_info is not implemented" do
assert_raises NotImplementedError do
@carrier.find_tracking_info(nil)
end
end
- def test_maximum_weight
- assert_equal Quantified::Mass.new(150, :pounds), @carrier.maximum_weight
+ test "#available_services is not implemented" do
+ assert_raises NotImplementedError do
+ @carrier.available_services(nil, nil)
+ end
end
- def test_maximum_address_field_length
+ test "#maximum_weight returns a Measured::Weight" do
+ assert_equal Measured::Weight.new(150, :pounds), @carrier.maximum_weight
+ end
+
+ test "#maximum_address_field_length default value" do
assert_equal 255, @carrier.maximum_address_field_length
end
- def test_requirements_empty_array
+ test "#requirements is an empty array" do
assert_equal [], @carrier.send(:requirements)
end
- def test_timestamp_from_business_day_returns_nil_without_a_day
+ test "#timestamp_from_business_day returns nil without a day" do
assert_nil @carrier.send(:timestamp_from_business_day, nil)
end
- def test_save_request
+ test "#save_request caches the last request on the object" do
request = Object.new
assert_nil @carrier.last_request
@carrier.send(:save_request, request)
assert_equal request, @carrier.last_request
end
- def test_timestamp_from_business_day_returns_two_days_in_the_future
+ test "#timestamp_from_business_day returns two days in the future" do
current = DateTime.parse("Tue 19 Jul 2016")
expected = DateTime.parse("Thu 21 Jul 2016")
Timecop.freeze(current) do
assert_equal expected, @carrier.send(:timestamp_from_business_day, 2)
end
end
- def test_timestamp_from_business_day_returns_two_days_in_the_future_over_a_weekend
+ test "#timestamp_from_business_day returns two days in the future over a weekend" do
current = DateTime.parse("Fri 22 Jul 2016")
expected = DateTime.parse("Tue 26 Jul 2016")
Timecop.freeze(current) do
assert_equal expected, @carrier.send(:timestamp_from_business_day, 2)
end
end
- def test_timestamp_from_business_day_returns_fifteen_days_in_the_future
+ test "#timestamp_from_business_day returns fifteen days in the future" do
current = DateTime.parse("Wed 06 Jul 2016")
expected = DateTime.parse("Wed 27 Jul 2016") # includes 3 weekends
Timecop.freeze(current) do
assert_equal expected, @carrier.send(:timestamp_from_business_day, 15)
end
end
- def test_timestamp_from_business_day_handles_saturday
+ test "#timestamp_from_business_day handles saturday" do
current = DateTime.parse("Sat 09 Jul 2016")
expected = DateTime.parse("Mon 11 Jul 2016")
Timecop.freeze(current) do
assert_equal expected, @carrier.send(:timestamp_from_business_day, 1)
end
end
- def test_timestamp_from_business_day_handles_sunday
+ test "#timestamp_from_business_day handles sunday" do
current = DateTime.parse("Sun 10 Jul 2016")
expected = DateTime.parse("Mon 11 Jul 2016")
Timecop.freeze(current) do
assert_equal expected, @carrier.send(:timestamp_from_business_day, 1)
end
end
- def test_timestamp_from_business_day_returns_datetime
+ test "#timestamp_from_business_day returns a DateTime" do
Timecop.freeze(DateTime.parse("Tue 19 Jul 2016")) do
assert_equal DateTime, @carrier.send(:timestamp_from_business_day, 1).class
end
end
- def test_default_location
+ test ".default_location is a valid address with defaults" do
result = Carrier.default_location
assert_equal Location, result.class
assert_equal ActiveUtils::Country.find("US"), result.country
assert_equal "CA", result.state
@@ -118,13 +124,7 @@
assert_equal "455 N. Rexford Dr.", result.address1
assert_equal "3rd Floor", result.address2
assert_equal "90210", result.zip
assert_equal "1-310-285-1013", result.phone
assert_equal "1-310-275-8159", result.fax
- end
-
- def test_available_services_is_not_implemented
- assert_raises NotImplementedError do
- @carrier.available_services(nil, nil)
- end
end
end