From f477f811df7530e96d085e66a485fe9280e149f5 Mon Sep 17 00:00:00 2001 From: Adam Roben Date: Tue, 6 Jan 2015 10:03:23 -0500 Subject: [PATCH] Extract TestGrammars#submodule_paths method --- test/test_grammars.rb | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/test/test_grammars.rb b/test/test_grammars.rb index a80e690d..ae24caf6 100644 --- a/test/test_grammars.rb +++ b/test/test_grammars.rb @@ -14,12 +14,11 @@ class TestGrammars < Minitest::Test end def test_submodules_are_in_sync - submodules = `git config --list --file "#{File.join(ROOT, ".gitmodules")}"`.lines.grep(/\.path=/).map { |line| line.chomp.split("=", 2).last } # Strip off paths inside the submodule so that just the submodule path remains. listed_submodules = @grammars.keys.grep(/vendor\/grammars/).map { |source| source[%r{vendor/grammars/[^/]+}] } - nonexistent_submodules = listed_submodules - submodules - unlisted_submodules = submodules - listed_submodules + nonexistent_submodules = listed_submodules - submodule_paths + unlisted_submodules = submodule_paths - listed_submodules message = "" unless nonexistent_submodules.empty? @@ -49,4 +48,10 @@ class TestGrammars < Minitest::Test assert_equal v, actual[k], "The scopes listed for #{k} in grammars.yml don't match the scopes found in that repository" end end + + private + + def submodule_paths + @submodule_paths ||= `git config --list --file "#{File.join(ROOT, ".gitmodules")}"`.lines.grep(/\.path=/).map { |line| line.chomp.split("=", 2).last } + end end