Skip to content

Commit f2b16fd

Browse files
committed
Add spec for validate! error message referencing bin/codeownership validate
Verifies that when CODEOWNERS is out of date and validate! is called with autocorrect: false, the error message references bin/codeownership validate rather than the standalone codeowners generate CLI command.
1 parent fd38b53 commit f2b16fd

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

spec/lib/code_ownership_spec.rb

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -555,4 +555,28 @@
555555
end
556556
end
557557
end
558+
559+
describe '.validate!' do
560+
context 'when the CODEOWNERS file is out of date' do
561+
before do
562+
create_non_empty_application
563+
RustCodeOwners.generate_and_validate(nil, false)
564+
# Add a new annotated file to make the CODEOWNERS file out of date
565+
write_file('packs/my_pack/new_file.rb', "# @team Bar\nclass NewFile; end\n")
566+
end
567+
568+
it 'raises an error referencing bin/codeownership validate' do
569+
expect { CodeOwnership.validate!(autocorrect: false) }.to raise_error(
570+
RuntimeError,
571+
/Run `bin\/codeownership validate/
572+
)
573+
end
574+
575+
it 'does not reference the standalone codeowners CLI' do
576+
expect { CodeOwnership.validate!(autocorrect: false) }.to raise_error(RuntimeError) do |error|
577+
expect(error.message).not_to include('`codeowners generate`')
578+
end
579+
end
580+
end
581+
end
558582
end

0 commit comments

Comments
 (0)