Skip to content

Commit

Permalink
Merge pull request #633 from Shopify/ko/quote-config
Browse files Browse the repository at this point in the history
Wrap options_string values in quotes
  • Loading branch information
KaanOzkan authored Jan 27, 2025
2 parents 7afab9d + e2518a0 commit 06f9139
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 4 deletions.
6 changes: 3 additions & 3 deletions lib/spoom/sorbet/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ def copy
sig { returns(String) }
def options_string
opts = []
opts.concat(paths)
opts.concat(ignore.map { |p| "--ignore #{p}" })
opts.concat(allowed_extensions.map { |ext| "--allowed-extension #{ext}" })
opts.concat(paths.map { |p| "'#{p}'" })
opts.concat(ignore.map { |p| "--ignore '#{p}'" })
opts.concat(allowed_extensions.map { |ext| "--allowed-extension '#{ext}'" })
opts << "--no-stdlib" if @no_stdlib
opts.join(" ")
end
Expand Down
35 changes: 35 additions & 0 deletions test/spoom/cli/srb/coverage_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,41 @@ 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\n--ignore=*.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

private

def create_git_history!
Expand Down
7 changes: 6 additions & 1 deletion test/spoom/sorbet/config_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,12 @@ def test_options_string_with_options
--allowed-extension=.rb
--no-stdlib
CONFIG
assert_equal(". --ignore .git/ --ignore vendor/ --allowed-extension .rb --no-stdlib", config.options_string)
expected = "'.' " \
"--ignore '.git/' " \
"--ignore 'vendor/' " \
"--allowed-extension '.rb' " \
"--no-stdlib"
assert_equal(expected, config.options_string)
end
end
end
Expand Down

0 comments on commit 06f9139

Please sign in to comment.