Move away from RSpec's described_class#22307
Conversation
MikeMcQuaid
left a comment
There was a problem hiding this comment.
Sorry to be that guy: now I'm actually looking at the diff, I kinda hate it 😭.
Could we do something like a type alias or e.g. test_alias = Homebrew::API::Cask::CaskStructGenerator to have RSpec handle this better with Sorbet while avoiding the excessive repetition?
Hah, it is quite a lot of diff.
To avoid the excessive repetition |
Works for me! |
a04db9c to
9292fa6
Compare
374e964 to
66b86b8
Compare
- The "explicit" setting on the `RSpec/DescribedClass` cop is still
enabled, because `described_class` is bad for Sorbet typing, but
instead of applying its autocorrections to specify the full class name
everywhere that `described_class` was used, use
`let(:klass) { Foo }` so that the repetition per-test isn't massive in
tests that use it a lot (say, >5 times).
- Changes made with Copilot CLI, agent mode, Claude Opus 4.7.
66b86b8 to
461521f
Compare
brew lgtm(style, typechecking and tests) with your changes locally?When we moved away from using the RuboCop autocorrections for
described_classreplacements with class names everywhere, I used Copilot with Claude Opus 4.7 in Agent mode to make the changes in commit adf7123 to addlet(:klass) { Foo }and replacedescribed_classwithklassin all the places.