Skip to content

Commit ab4fc9a

Browse files
committed
BUFIX: deprecation_tracker breaking with unknown keywords
1 parent 3d35c23 commit ab4fc9a

File tree

4 files changed

+22
-4
lines changed

4 files changed

+22
-4
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55

66
* Your changes/patches go here.
77

8+
# v1.4.7 / 2025-05-20 [(commits)](https://github.com/fastruby/next_rails/compare/v1.4.6...v1.4.7)
9+
10+
- [BUFIX: deprecation_tracker breaking with unknown keywords](https://github.com/fastruby/next_rails/pull/150)
11+
812
# v1.4.6 / 2025-04-15 [(commits)](https://github.com/fastruby/next_rails/compare/v1.4.5...v1.4.6)
913

1014
- [BUFIX: Fix compatibilities performance bug](https://github.com/fastruby/next_rails/pull/150)

lib/deprecation_tracker.rb

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def self.callbacks
1818
@callbacks ||= []
1919
end
2020

21-
def warn(*messages, uplevel: nil, category: nil)
21+
def warn(*messages, uplevel: nil, category: nil, **kwargs)
2222
KernelWarnTracker.callbacks.each do |callback|
2323
messages.each { |message| callback.(message) }
2424
end
@@ -28,7 +28,11 @@ def warn(*messages, uplevel: nil, category: nil)
2828
elsif Gem::Version.new(RUBY_VERSION) < Gem::Version.new("3.0")
2929
super(*messages, uplevel: nil)
3030
else
31-
super
31+
begin
32+
super(*messages, uplevel: uplevel, category: category, **kwargs)
33+
rescue ArgumentError => e
34+
super(*messages, uplevel: uplevel, category: category)
35+
end
3236
end
3337
end
3438
end
@@ -43,7 +47,7 @@ def before_setup
4347
@@deprecation_tracker.bucket = test_file_name.gsub(Rails.root.to_s, ".")
4448
super
4549
end
46-
50+
4751
def after_teardown
4852
super
4953
@@deprecation_tracker.bucket = nil

lib/next_rails/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# frozen_string_literal: true
22

33
module NextRails
4-
VERSION = "1.4.6"
4+
VERSION = "1.4.7"
55
end

spec/deprecation_tracker_spec.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,5 +330,15 @@ def self.behavior
330330
end
331331
end
332332
end
333+
334+
describe "bug when warning uses unexpected keyword arguments" do
335+
it "does not raise an error with unknown keyword args like :deprecation, :span, :stack" do
336+
DeprecationTracker::KernelWarnTracker.callbacks << -> (message) { message.to_s }
337+
338+
expect {
339+
warn("Unknown deprecation warning", deprecation: true, span: 1.2, stack: ["line1", "line2"])
340+
}.to not_raise_error.and output.to_stderr
341+
end
342+
end
333343
end
334344
end

0 commit comments

Comments
 (0)