File tree Expand file tree Collapse file tree 2 files changed +83
-1
lines changed Expand file tree Collapse file tree 2 files changed +83
-1
lines changed Original file line number Diff line number Diff line change @@ -38,8 +38,24 @@ def hash
3838 identifier . hash
3939 end
4040
41+ ##
42+ # Does this locked specification satisfy +dependency+?
43+ #
44+ # NOTE: Rubygems default requirement is ">= 0", which doesn't match
45+ # prereleases of 0 versions, like "0.0.0.dev" or "0.0.0.SNAPSHOT". However,
46+ # bundler users expect those to work. We need to make sure that Gemfile
47+ # dependencies without explicit requirements (which use ">= 0" under the
48+ # hood by default) are still valid for locked specs using this kind of
49+ # versions. The method implements an ad-hoc fix for that. A better solution
50+ # might be to change default rubygems requirement of dependencies to be ">=
51+ # 0.A" but that's a major refactoring likely to break things. Hopefully we
52+ # can attempt it in the future.
53+ #
54+
4155 def satisfies? ( dependency )
42- @name == dependency . name && dependency . requirement . satisfied_by? ( Gem ::Version . new ( @version ) )
56+ effective_requirement = dependency . requirement == Gem ::Requirement . default ? Gem ::Requirement . new ( ">= 0.A" ) : dependency . requirement
57+
58+ @name == dependency . name && effective_requirement . satisfied_by? ( Gem ::Version . new ( @version ) )
4359 end
4460
4561 def to_lock
Original file line number Diff line number Diff line change 183183 expect ( the_bundle ) . to include_gems "foo 1.0"
184184 end
185185
186+ it "works when using prereleases of 0.0.0" do
187+ build_lib "foo" , "0.0.0.dev" , :path => lib_path ( "foo" )
188+
189+ gemfile <<~G
190+ source "#{ file_uri_for ( gem_repo1 ) } "
191+ gem "foo", :path => "#{ lib_path ( "foo" ) } "
192+ G
193+
194+ lockfile <<~L
195+ PATH
196+ remote: #{ lib_path ( "foo" ) }
197+ specs:
198+ foo (0.0.0.dev)
199+
200+ GEM
201+ remote: #{ file_uri_for ( gem_repo1 ) } /
202+ specs:
203+
204+ PLATFORMS
205+ #{ lockfile_platforms }
206+
207+ DEPENDENCIES
208+ foo!
209+
210+ BUNDLED WITH
211+ #{ Bundler ::VERSION }
212+ L
213+
214+ bundle :install
215+
216+ expect ( the_bundle ) . to include_gems "foo 0.0.0.dev"
217+ end
218+
219+ it "works when using uppercase prereleases of 0.0.0" do
220+ build_lib "foo" , "0.0.0.SNAPSHOT" , :path => lib_path ( "foo" )
221+
222+ gemfile <<~G
223+ source "#{ file_uri_for ( gem_repo1 ) } "
224+ gem "foo", :path => "#{ lib_path ( "foo" ) } "
225+ G
226+
227+ lockfile <<~L
228+ PATH
229+ remote: #{ lib_path ( "foo" ) }
230+ specs:
231+ foo (0.0.0.SNAPSHOT)
232+
233+ GEM
234+ remote: #{ file_uri_for ( gem_repo1 ) } /
235+ specs:
236+
237+ PLATFORMS
238+ #{ lockfile_platforms }
239+
240+ DEPENDENCIES
241+ foo!
242+
243+ BUNDLED WITH
244+ #{ Bundler ::VERSION }
245+ L
246+
247+ bundle :install
248+
249+ expect ( the_bundle ) . to include_gems "foo 0.0.0.SNAPSHOT"
250+ end
251+
186252 it "handles downgrades" do
187253 build_lib "omg" , "2.0" , :path => lib_path ( "omg" )
188254
You can’t perform that action at this time.
0 commit comments