@@ -314,11 +314,9 @@ module CodeOwnership
314314 CODEOWNERS out of date. Run `bin/codeownership validate` to update the CODEOWNERS file
315315
316316 CODEOWNERS should contain the following lines, but does not:
317- - ""
318317 - "/packs/my_pack/owned_file.rb @MyOrg/bar-team"
319318 - "# Owner metadata key in package.yml"
320319 - "/packs/my_other_package/**/** @MyOrg/bar-team"
321- - ""
322320
323321 CODEOWNERS should not contain the following lines, but it does:
324322 - "/frontend/some/extra/line/that/should/not/exist @MyOrg/bar-team"
@@ -420,17 +418,53 @@ module CodeOwnership
420418 CODEOWNERS out of date. Run `bin/codeownership validate` to update the CODEOWNERS file
421419
422420 CODEOWNERS should contain the following lines, but does not:
423- - ""
424421 - "/packs/my_pack/owned_file.rb @MyOrg/bar-team"
425422 - "# Owner metadata key in package.yml"
426423 - "/packs/my_other_package/**/** @MyOrg/bar-team"
427- - ""
428424
429425 See https://github.com/rubyatscale/code_ownership#README.md for more details
430426 EXPECTED
431427 end
432428 end
433429 end
430+
431+ context 'in an application with a CODEOWNERS file with no issue' do
432+ before { create_non_empty_application }
433+
434+ it 'prints out the diff' do
435+ FileUtils . mkdir ( '.github' )
436+ codeowners_path . write <<~CODEOWNERS
437+ # STOP! - DO NOT EDIT THIS FILE MANUALLY
438+ # This file was automatically generated by "bin/codeownership validate".
439+ #
440+ # CODEOWNERS is used for GitHub to suggest code/file owners to various GitHub
441+ # teams. This is useful when developers create Pull Requests since the
442+ # code/file owner is notified. Reference GitHub docs for more details:
443+ # https://help.github.com/en/articles/about-code-owners
444+
445+
446+ # Annotations at the top of file
447+ /frontend/javascripts/packages/my_package/owned_file.jsx @MyOrg/bar-team
448+ /packs/my_pack/owned_file.rb @MyOrg/bar-team
449+
450+ # Owner metadata key in package.yml
451+ /packs/my_other_package/**/** @MyOrg/bar-team
452+
453+ # Team-specific owned globs
454+ /app/services/bar_stuff/** @MyOrg/bar-team
455+ /frontend/javascripts/bar_stuff/** @MyOrg/bar-team
456+
457+ # Owner metadata key in package.json
458+ /frontend/javascripts/packages/my_other_package/**/** @MyOrg/bar-team
459+
460+ # Team YML ownership
461+ /config/teams/bar.yml @MyOrg/bar-team
462+ CODEOWNERS
463+
464+ expect_any_instance_of ( codeowners_validation ) . to_not receive ( :` ) # rubocop:disable RSpec/AnyInstance
465+ expect { CodeOwnership . validate! ( autocorrect : false ) } . to_not raise_error
466+ end
467+ end
434468 end
435469
436470 context 'code_ownership.yml has skip_codeowners_validation set' do
0 commit comments