Cleanup parser specs#15446
Conversation
|
I too prefer unrolled loops for explicitness and grepability. The loops however do provide value in grouping: They express that all examples are functionally equivalent, just testing different values. Some sense of togetherness could be established by grouping the examples via The other aspect of functional equivalence has particular relevance for more complex examples: Generalizing the implementation helps keep the code clean and easy to read. For example, extract the shared plumbing into a spec helper method and let the unrolled loop items call that explicitly. Perhaps that could be a strategy to explore for further enhancements of the more complex loops not touched in thie PR. # loop
%[a b c].each do |value|
it "#{value} foo" do
assert_fooing(value)
end
end
# unrolled with helper
private def it_foos(value)
it "#{value}.foo" do
assert_fooing(value)
end
end
it_foos "a"
it_foos "b"
it_foos "c"For this PR I'd like to have the former loops grouped into describe blocks. |
ysbaddaden
left a comment
There was a problem hiding this comment.
To be honest, I fail to see the benefit of unrolling the loops 🤷
|
Benefits:
|
Note: Commit ea79701 may be controversial. I slightly prefer explicit test cases over loops, but I have no strong feelings either way!