Skip to content

Add spec for Warning.categories #1272

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions core/warning/categories_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
require_relative '../../spec_helper'

ruby_version_is "3.4" do
describe "Warning.categories" do
it "returns the list of possible warning categories" do
Warning.categories.sort.should == [:deprecated, :experimental, :performance, :strict_unused_block]
end
Copy link
Member

@andrykonchin andrykonchin May 29, 2025

Choose a reason for hiding this comment

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

Not sure if the list should be hardcoded this way. For instance the last category (:strict_unused_block) isn't documented in https://ruby-doc.org/3.4.1/Warning.html. And I can imagine that some alternative Ruby implementation may provide some additional non-standard categories.

Copy link
Member

Choose a reason for hiding this comment

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

Right, I think it's best to check the first 3 are included like .should.include? :deprecated, and not test :strict_unused_block or prohibit other somewhat-implementation-specific categories.

Copy link
Member

@eregon eregon May 29, 2025

Choose a reason for hiding this comment

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

i.e. if a Ruby implementation doesn't implement the unused block warning it shouldn't list :strict_unused_block and it should still be able to pass this spec as this list is useful to let gems/users know what kind of warnings are available.

end
end