From aa9fc58aacb934f07dc25fa249f8f7a92932ba4f Mon Sep 17 00:00:00 2001 From: Kaan Ozkan Date: Thu, 23 Jan 2025 14:55:00 -0500 Subject: [PATCH] Add coverage test that utilizes options parsing --- test/spoom/cli/srb/coverage_test.rb | 71 +++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) diff --git a/test/spoom/cli/srb/coverage_test.rb b/test/spoom/cli/srb/coverage_test.rb index 32f397a8..84bd2108 100644 --- a/test/spoom/cli/srb/coverage_test.rb +++ b/test/spoom/cli/srb/coverage_test.rb @@ -488,6 +488,77 @@ def test_finish_on_original_branch assert_equal("fake-branch", @project.git_current_branch) end + def test_config_options_string + # Add ignore path to config to test config options string + @project.write!("sorbet/config", "\n--ignore=lib/a.rb", append: true) + + result = @project.spoom("srb coverage snapshot") + out = censor_sorbet_version(result.out) + assert_equal(<<~MSG, out) + Sorbet static: X.X.XXXX + Sorbet runtime: X.X.XXXX + + Content: + files: 3 + files excluding rbis: 2 + modules: 3 + classes: 1 + methods: 9 + methods excluding rbis: 9 + + Sigils: + true: 3 (100%) + + Methods: + with signature: 2 (22%) + without signature: 7 (78%) + + Methods excluding RBIs + with signature: 2 (22%) + without signature: 7 (78%) + + Calls: + typed: 4 (67%) + untyped: 2 (33%) + MSG + end + + def test_config_options_string_ignores_wildcard + # Add ignore path to config to test config options string + @project.write!("sorbet/config", "\n--ignore=*/a.rb", append: true) + + result = @project.spoom("srb coverage snapshot") + out = censor_sorbet_version(result.out) + assert_equal(<<~MSG, out) + Sorbet static: X.X.XXXX + Sorbet runtime: X.X.XXXX + + Content: + files: 4 + files excluding rbis: 3 + modules: 5 + classes: 2 + methods: 14 + methods excluding rbis: 14 + + Sigils: + false: 1 (25%) + true: 3 (75%) + + Methods: + with signature: 2 (14%) + without signature: 12 (86%) + + Methods excluding RBIs + with signature: 2 (14%) + without signature: 12 (86%) + + Calls: + typed: 5 (83%) + untyped: 1 (17%) + MSG + end + private def create_git_history!