Rails fixture accessors have used `method_missing` since Rails 7.1 instead of generated methods, creating a silent collision risk. When turbo-rails is in the Gemfile, it includes `ActionCable::TestHelper` into every test case, which defines a real `broadcasts` instance method. This real method wins over `method_missing`, so `broadcasts(:announcement)` returns an empty Array instead of the fixture record. The bug is flaky locally because `ActionCable::Server::Base` is only autoloaded on first reference, but consistent in CI where eager loading is enabled. Four fixes are presented: use the documented `fixture(:broadcasts, :announcement)` accessor, query the model directly, rename the fixture file, or force eager loading to make failures deterministic. A script is provided to audit any Rails suite for fixture name collisions.

10m read timeFrom codewithrails.com
Post cover image
Table of contents
The symptom that made no senseHow Rails resolves a fixture accessorThe huntWhy it was flakyThe fixThe general lesson

Sort: