Next Next commit
BUFIX: deprecation_tracker breaking with unknown keywords
  • Loading branch information
@julioalucero
julioalucero committedMay 23, 2025
commit 5e1ea9a7380a3679df2a5e4d474ba99dfcc97f9d
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,6 +6,10 @@

* Your changes/es go here.

# v1.4.7 / 2025-05-20 [(commits)](https://.com/fastruby/next_rails/compare/v1.4.6...v1.4.7)

- [BUFIX: deprecation_tracker breaking with unknown keywords](https://.com/fastruby/next_rails/pull/156)

# v1.4.6 / 2025-04-15 [(commits)](https://.com/fastruby/next_rails/compare/v1.4.5...v1.4.6)

- [BUFIX: Fix compatibilities performance bug](https://.com/fastruby/next_rails/pull/150)
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -18,7 +18,7 @@ def self.callbacks
@callbacks ||= []
end

def warn(*messages, uplevel: nil, category: nil)
def warn(*messages, uplevel: nil, category: nil, **kwargs)
KernelWarnTracker.callbacks.each do |callback|
messages.each { |message| callback.(message) }
end
Expand All@@ -28,7 +28,11 @@ def warn(*messages, uplevel: nil, category: nil)
elsif Gem::Version.new(RUBY_VERSION) < Gem::Version.new("3.0")
super(*messages, uplevel: nil)
else
super
begin
super(*messages, uplevel: uplevel, category: category, **kwargs)
rescue ArgumentError => e
super(*messages, uplevel: uplevel, category: category)
end
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@julioalucero if you know when the signature of the method changed, it would be best to use if/else vs. begin/rescue

end
end
end
Expand All@@ -43,7 +47,7 @@ def before_setup
@@deprecation_tracker.bucket = test_file_name.gsub(Rails.root.to_s, ".")
super
end

def after_teardown
super
@@deprecation_tracker.bucket = nil
Expand Down
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module NextRails
VERSION = "1.4.6"
VERSION = "1.4.7"
end
Original file line numberDiff line numberDiff line change
Expand Up@@ -330,5 +330,15 @@ def self.behavior
end
end
end

describe "bug when warning uses unexpected keyword arguments" do
it "does not raise an error with unknown keyword args like :deprecation, :span, :stack" do
DeprecationTracker::KernelWarnTracker.callbacks << -> (message) { message.to_s }

expect {
warn("Unknown deprecation warning", deprecation: true, span: 1.2, stack: ["line1", "line2"])
}.to not_raise_error.and output.to_stderr
end
end
end
end