diff --git a/lib/pundit.rb b/lib/pundit.rb index 0ebda55..e8e7320 100644 --- a/lib/pundit.rb +++ b/lib/pundit.rb @@ -55,7 +55,9 @@ module Pundit class NotDefinedError < Error; end def self.included(base) - warn "[DEPRECATION] 'include Pundit' is deprecated. Please use 'include Pundit::Authorization' instead." + ActiveSupport::Deprecation.warn <<~WARNING.strip_heredoc + 'include Pundit' is deprecated. Please use 'include Pundit::Authorization' instead. + WARNING base.include Authorization end diff --git a/spec/pundit_spec.rb b/spec/pundit_spec.rb index 5f3bdb5..beb6b52 100644 --- a/spec/pundit_spec.rb +++ b/spec/pundit_spec.rb @@ -398,18 +398,23 @@ RSpec.describe Pundit do describe ".included" do it "includes Authorization module" do klass = Class.new - klass.include Pundit + + ActiveSupport::Deprecation.silence do + klass.include Pundit + end expect(klass).to include Pundit::Authorization end it "warns about deprecation" do - allow(Pundit).to receive(:warn) - klass = Class.new - klass.include Pundit + allow(ActiveSupport::Deprecation).to receive(:warn) - expect(Pundit).to have_received(:warn).with start_with("[DEPRECATION]") + ActiveSupport::Deprecation.silence do + klass.include Pundit + end + + expect(ActiveSupport::Deprecation).to have_received(:warn).with start_with("'include Pundit' is deprecated") end end