File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -1096,4 +1096,22 @@ If you need to call a subview that expects an instance variable be set. If possi
10961096
10971097Unfortunately the only way to get data into a layout template is with instance variables. You can't explicitly pass locals to them.
10981098
1099+
1100+ ### Avoid ` Class#descendants `
1101+
1102+ Avoid using ` Class#descendants ` as it is unreliable.
1103+ It doesn't know about classes that haven't been autoloaded yet, and it's non-deterministic with regards to garbage collection of classes.
1104+ In tests that dynamically define classes, GC timing can mean ` Class#descendants ` may or may not include those dynamically defined classes.
1105+
1106+ ``` ruby
1107+ # bad
1108+ class Person < ApplicationRecord
1109+ end
1110+
1111+ class Employee < Person
1112+ end
1113+
1114+ Person .descendants # => Unreliable, may or may not include Employee
1115+ ```
1116+
10991117[ rubocop-guide ] : https://github.com/rubocop-hq/ruby-style-guide
You can’t perform that action at this time.
0 commit comments