Skip to content

Commit 4c8b961

Browse files
committed
Add coverage test that utilizes options parsing
1 parent dac0d85 commit 4c8b961

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

test/spoom/cli/srb/coverage_test.rb

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,11 +446,15 @@ def test_timeline_with_path_option
446446
end
447447

448448
def test_report_outside_sorbet_dir
449+
sorbet_config = @project.read("sorbet/config")
449450
@project.remove!("sorbet/config")
450451
result = @project.spoom("srb coverage report --no-color")
451452
assert_empty(result.out)
452453
assert_equal("Error: not in a Sorbet project (`sorbet/config` not found)", result.err&.lines&.first&.chomp)
453454
refute(result.status)
455+
456+
# Restore original config
457+
@project.write!("sorbet/config", sorbet_config)
454458
end
455459

456460
def test_report_without_any_data
@@ -488,6 +492,45 @@ def test_finish_on_original_branch
488492
assert_equal("fake-branch", @project.git_current_branch)
489493
end
490494

495+
def test_config_options_string
496+
sorbet_config = @project.read("sorbet/config")
497+
# Add ignore path to config to test config options string
498+
@project.write!("sorbet/config", "\n--ignore=lib/a.rb", append: true)
499+
500+
result = @project.spoom("srb coverage snapshot")
501+
out = censor_sorbet_version(result.out)
502+
assert_equal(<<~MSG, out)
503+
Sorbet static: X.X.XXXX
504+
Sorbet runtime: X.X.XXXX
505+
506+
Content:
507+
files: 3
508+
files excluding rbis: 2
509+
modules: 3
510+
classes: 1
511+
methods: 9
512+
methods excluding rbis: 9
513+
514+
Sigils:
515+
true: 3 (100%)
516+
517+
Methods:
518+
with signature: 2 (22%)
519+
without signature: 7 (78%)
520+
521+
Methods excluding RBIs
522+
with signature: 2 (22%)
523+
without signature: 7 (78%)
524+
525+
Calls:
526+
typed: 4 (67%)
527+
untyped: 2 (33%)
528+
MSG
529+
530+
# Restore original config
531+
@project.write!("sorbet/config", sorbet_config)
532+
end
533+
491534
private
492535

493536
def create_git_history!

0 commit comments

Comments
 (0)