test/units/path_test.rb in imgix-3.2.1 vs test/units/path_test.rb in imgix-3.3.0

- old
+ new

@@ -1,10 +1,31 @@ # frozen_string_literal: true require 'test_helper' class PathTest < Imgix::Test + def test_prefix_with_arg_warns + prefix_warn = "Warning: `Client::prefix' will take zero arguments " \ + "in the next major version.\n" + + assert_output(nil, prefix_warn) { + Imgix::Client.new( + domain: 'test.imgix.net', + include_library_param: false + ).prefix("") + } + + # `new_prefix' is a placeholder until the bump, when it will become + # `prefix`. + assert_output(nil, nil) { + Imgix::Client.new( + domain: 'test.imgix.net', + include_library_param: false + ).new_prefix + } + end + def test_creating_a_path path = client.path('/images/demo.png') assert_equal 'https://demo.imgix.net/images/demo.png?s=2c7c157eaf23b06a0deb2f60b81938c4', path.to_url path = client.path('images/demo.png') @@ -12,25 +33,40 @@ end def test_signing_path_with_param url = 'https://demo.imgix.net/images/demo.png?w=200&s=da421114ca238d1f4a927b889f67c34e' path = client.path('/images/demo.png') - path.width = 200 + assert_output(nil, "Warning: `Path.width=' has been deprecated and " \ + "will be removed in the next major version (along " \ + "with all parameter `ALIASES`).\n") { + path.width = 200 + } + assert_equal url, path.to_url path = client.path('/images/demo.png') assert_equal url, path.to_url(w: 200) path = client.path('/images/demo.png') - assert_equal url, path.width(200).to_url + + assert_output(nil, "Warning: `Path.width' has been deprecated and " \ + "will be removed in the next major version (along " \ + "with all parameter `ALIASES`).\n") { + assert_equal url, path.width(200).to_url + } end def test_resetting_defaults url = 'https://demo.imgix.net/images/demo.png?w=200&s=da421114ca238d1f4a927b889f67c34e' path = client.path('/images/demo.png') - path.height = 300 + + assert_output(nil, "Warning: `Path.height=' has been deprecated and " \ + "will be removed in the next major version (along " \ + "with all parameter `ALIASES`).\n") { + path.height = 300 + } assert_equal url, path.defaults.to_url(w: 200) end def test_path_with_multiple_params @@ -38,10 +74,24 @@ path = client.path('/images/demo.png') assert_equal url, path.to_url(h: 200, w: 200) path = client.path('/images/demo.png') - assert_equal url, path.height(200).width(200).to_url + + assert_output(nil, "Warning: `Path.height' has been deprecated and " \ + "will be removed in the next major version (along " \ + "with all parameter `ALIASES`).\n") { + path.height(200) + } + + + assert_output(nil, "Warning: `Path.width' has been deprecated and " \ + "will be removed in the next major version (along " \ + "with all parameter `ALIASES`).\n") { + path.width(200) + } + + assert_equal url, path.to_url end def test_path_with_multi_value_param_safely_encoded url = 'https://demo.imgix.net/images/demo.png?markalign=middle%2Ccenter&s=f0d0e28a739f022638f4ba6dddf9b694' path = client.path('/images/demo.png')