New cop to disallow before and a single test case
It makes little sense to write the test code like
context 'when something' do
before do
# some setup
end
it 'tests something' do # <--- only one test case
# some testing
end
end
The test is now unnecessary segregated. When more before blocks precedes it outside of the context it is even harder to combine all these pieces.
Better is to write it like
context 'when something' do
it 'tests something' do
# some setup
# some testing
end
end
Using DSL elements such as context, before, and it appropriately can be viewed as valid. So, it’s doubtful whether this should be regarded as "redundant" or as an appropriate use of vocabulary, as it depend on individual judgment. Forcing these to fit into a single line universally doesn’t seem reasonable. Even if this cop will be implemented, it should be disabled by default.
IMO, I am reluctant to add this cop. Our project goal is to enforce the guidelines and best practices outlined in the community RSpec style guide. Currently, I am skeptical about whether this approach qualifies as a best practice. As a first step, it might be better to start by discussing in the RSpec Style Guide.