Skip to content

Improve validate_inclusion_of matcher boolean warn messages#1692

Merged
matsales28 merged 1 commit intothoughtbot:mainfrom
hexdevs:sb-improve-warning-messages-1688
Jan 9, 2026
Merged

Improve validate_inclusion_of matcher boolean warn messages#1692
matsales28 merged 1 commit intothoughtbot:mainfrom
hexdevs:sb-improve-warning-messages-1688

Conversation

@stefannibrasil
Copy link
Contributor

@stefannibrasil stefannibrasil commented Dec 16, 2025

Closes #1688

The generated warn messages for the validate_inclusion_of matcher do not include the model/attribute names, which makes it hard to know where to look at to update/remove the tests.

Following the library's existing warn messages behaviour of including the attribute in the message, I did the same here. I believe this is a simple but helpful improvement to help users fix those warnings. For example: https://github.com/thoughtbot/shoulda-matchers/blob/main/lib/shoulda/matchers/active_model/errors.rb#L17

I did consider adding the line/caller location, but I didn't find an example of that in the library, and decided to propose simply adding the model#attribute names.

Is this enough? Happy to try a different approach :)

Ruby script showing an example of the improved warn message: https://gist.github.com/stefannibrasil/fcc8362bbd050e4f3bcc568b9fc7ec9d

Closes thoughtbot#1688

The generated warn messages for the validate_inclusion_of matcher do not include
the model/attribute names, which makes it hard to know where
to look at to update/remove the tests.

Following the library's existing warn messages behaviour
of including the attribute in the message, I did the same here.
I believe this is a simple but helpful improvement to help
users fix those warnings. For example: https://github.com/thoughtbot/shoulda-matchers/blob/main/lib/shoulda/matchers/active_model/errors.rb#L17

I did consider adding the line/caller location, but I didn't
find an example of that in the library, and decided to propose
simply adding the model#attribute names.
@matsales28 matsales28 merged commit fa4c9d5 into thoughtbot:main Jan 9, 2026
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update validate_inclusion_of warning message about boolean columns to include model name and column name

2 participants