Module: RuboCop::Cop::DevDoc::Test::JustificationHeader
- Included in:
- RequireUnitTestJustification
- Defined in:
- lib/rubocop/cop/dev_doc/test/justification_header.rb
Overview
The justification-header contract shared by test-placement cops: a
justified non-HTTP test must open with leading comments (before the
first class/module) that contain the marker phrase (why a controller
test can't cover this) AND a wiring line (which request test still
covers the HTTP path its subject participates in — or why no runtime
HTTP path exists). Host cops must provide offense_range and
cop_config.
Constant Summary collapse
- MSG_JUSTIFY =
'Unit-test file without a justification header. Controller tests catch the ' \ 'wiring bugs unit tests miss, so first assume a controller test IS possible ' \ 'and look harder — that conclusion is almost always premature (see ' \ 'DevDoc/Test/AvoidUnitTest for patterns that reach "unit-only" behaviour ' \ 'end-to-end). If genuinely impossible, explain why in the leading comments, ' \ 'including the marker phrase "%<phrase>s".'.freeze
- MSG_JUSTIFY_WIRING =
' The header must also carry a "%<wiring>s" line naming the request ' \ 'test that still covers the HTTP wiring this test bypasses (or why ' \ 'no runtime HTTP path exists).'.freeze
- MSG_WIRING =
'Justification header lacks a "%<phrase>s" line. Every justified non-HTTP ' \ 'test must account for the HTTP wiring its subject participates in: name the ' \ 'request test that covers that path end-to-end, or state why no runtime HTTP ' \ 'path exists (naming the actual entry point — job, sync service, rake task). ' \ 'Writing this line is what catches a relocation that would silently strand a ' \ 'controller param, policy branch, or rendered error with no request-level ' \ 'coverage.'.freeze