1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

[rubygems/rubygems] Bundler: make to_lock consistent between Gem::Dependency and Bundler::Dependency

https://github.com/rubygems/rubygems/commit/971d57cf5a
This commit is contained in:
Aleksandr Varnin 2022-08-24 19:09:10 +03:00 committed by git
parent 13d2225c46
commit 381d8e43ce
3 changed files with 39 additions and 2 deletions

View file

@ -151,7 +151,7 @@ module Bundler
def to_lock
out = super
out << "!" if source
out << "\n"
out
end
def specific?

View file

@ -60,7 +60,7 @@ module Bundler
handled = []
definition.dependencies.sort_by(&:to_s).each do |dep|
next if handled.include?(dep.name)
out << dep.to_lock
out << dep.to_lock << "\n"
handled << dep.name
end
end

View file

@ -0,0 +1,37 @@
# frozen_string_literal: true
RSpec.describe Bundler::Dependency do
let(:options) do
{}
end
let(:dependency) do
described_class.new(
"test_gem",
"1.0.0",
options
)
end
describe "to_lock" do
it "returns formatted string" do
expect(dependency.to_lock).to eq(" test_gem (= 1.0.0)")
end
it "matches format of Gem::Dependency#to_lock" do
gem_dependency = Gem::Dependency.new("test_gem", "1.0.0")
expect(dependency.to_lock).to eq(gem_dependency.to_lock)
end
context "when source is passed" do
let(:options) do
{
"source" => Bundler::Source::Git.new({}),
}
end
it "returns formatted string with exclamation mark" do
expect(dependency.to_lock).to eq(" test_gem (= 1.0.0)!")
end
end
end
end