Preventing examples in loops #1782
BigBigDoudou
started this conversation in
Ideas
Replies: 1 comment
-
It will certainly be a good addition. Please note that we have a cop that would take it further and suggest Would you like to hack on it? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hey! 👋
In many specs, I see examples written dynamically inside loops:
However, it poses certain problems:
'/path_to_spec.rb[1:1:42]'
)eager_load
works inside a block, not outside, so doingApplicationRecord.descendants.each { it { ... } }
will not work because the models are not loaded.The idea would therefore be to have a cop that prevents examples in loops, so the specification should be replaced by:
Note that I use
aggregate_failures
to ensure that all elements of the enumerable are tested, as they were before.WDYT?
Beta Was this translation helpful? Give feedback.
All reactions