module GdsApi
  module TestHelpers
    module AliasDeprecated
      def alias_deprecated(deprecated_method, replacement_method)
        class_name = self.name
        define_method(deprecated_method) do |*args, &block|
          warn "##{deprecated_method} is deprecated on #{class_name} and will be removed in a future version. Use ##{replacement_method} instead"
          public_send(replacement_method, *args, &block)
        end
      end
    end
  end
end

Add a module for mixing in a deprecated alias
Add a module for mixing in a deprecated alias

This offers an alternative to alias_method for when we have a deprecated
method. It will still allow the old method to be called but whenever it
is a warning will be emitted. This is intended to help us actually
remove some of the deprecated methods by encouraging their discontinued
use.

There is a reasonable chance this may have some problems with the switch
to Ruby 2.7 [1]. Hopefully we're well on the way to removing these
before then.

[1] https://eregon.me/blog/2019/11/10/the-delegation-challenge-of-ruby27.html
