Skip to content

Commit

Permalink
Merge pull request #608 from Shopify/ko/gem-version-helper
Browse files Browse the repository at this point in the history
Return `Gem::Version` from `Bundle#gem_version_from_gemfile_lock`
  • Loading branch information
KaanOzkan authored Sep 30, 2024
2 parents 16bc1a5 + a900bc4 commit 3591176
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions lib/spoom/context/bundle.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ def gemfile_lock_specs
# Get `gem` version from the `Gemfile.lock` content
#
# Returns `nil` if `gem` cannot be found in the Gemfile.
sig { params(gem: String).returns(T.nilable(String)) }
sig { params(gem: String).returns(T.nilable(Gem::Version)) }
def gem_version_from_gemfile_lock(gem)
gemfile_lock_specs[gem]&.version&.to_s
gemfile_lock_specs[gem]&.version
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions lib/spoom/coverage.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ def snapshot(context, rbi: true, sorbet_bin: nil)
end
end

snapshot.version_static = context.gem_version_from_gemfile_lock("sorbet-static")
snapshot.version_runtime = context.gem_version_from_gemfile_lock("sorbet-runtime")
snapshot.version_static = context.gem_version_from_gemfile_lock("sorbet-static").to_s
snapshot.version_runtime = context.gem_version_from_gemfile_lock("sorbet-runtime").to_s

files = context.srb_files(with_config: new_config)
snapshot.rbi_files = files.count { |file| file.end_with?(".rbi") }
Expand Down
6 changes: 3 additions & 3 deletions test/spoom/context/bundle_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -143,15 +143,15 @@ def test_version_from_gemfile_lock_return_sorbet_version
STR
assert_equal(
"0.5.5001",
context.gem_version_from_gemfile_lock("sorbet"),
context.gem_version_from_gemfile_lock("sorbet").to_s,
)
assert_equal(
"0.5.5002",
context.gem_version_from_gemfile_lock("sorbet-runtime"),
context.gem_version_from_gemfile_lock("sorbet-runtime").to_s,
)
assert_equal(
"0.5.5003",
context.gem_version_from_gemfile_lock("sorbet-static"),
context.gem_version_from_gemfile_lock("sorbet-static").to_s,
)
end
end
Expand Down

0 comments on commit 3591176

Please sign in to comment.