0
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2026-08-07 13:19:19 +08:00
discourse/migrations/core/spec/support
Gerhard Schlager 79aa8c6a7f MT: Forbid send-style dispatch via Style/Send
Enable Style/Send for the migrations tree so we reach for methods directly
instead of poking them through `send`. Bare `send` bypasses method visibility,
and nearly all of our uses were either tearing down test constants or reaching
into a private method a spec wanted to exercise.

- Test-const teardown went through `Object.send(:remove_const, …)` across a
  bunch of specs. `remove_const` is private on Module by design, so I added one
  spec helper, `remove_test_const`, that keeps the single `send` behind a scoped
  disable, and converted every call site to it. That's the one sanctioned
  escape hatch.
- The private-probe specs (`require_positional!`, `filter_steps`, the plugin
  introspector methods) now expose the method through a small anonymous-subclass
  seam and call it directly, with the assertions unchanged.
- One parameterized spec looped over the public `include`/`include_all` DSL
  methods with `send`; that's now `public_send`.

Style/Send only flags bare `send` — `public_send`/`__send__` are the cop's own
recommended alternatives, so the two dynamic-dispatch lib sites (`public_send`
in attribute_assignment and step) already pass and need no disable.
2026-07-22 09:52:55 +02:00
..
fixtures/schema
matchers
shared_examples
tui
helpers.rb MT: Forbid send-style dispatch via Style/Send 2026-07-22 09:52:55 +02:00