|
289 | 289 | end |
290 | 290 | end |
291 | 291 |
|
| 292 | + describe "#precompute_source_requirements_for_indirect_dependencies?" do |
| 293 | + before do |
| 294 | + allow(Bundler::SharedHelpers).to receive(:find_gemfile) { Pathname.new("Gemfile") } |
| 295 | + end |
| 296 | + |
| 297 | + let(:sources) { Bundler::SourceList.new } |
| 298 | + subject { Bundler::Definition.new(nil, [], sources, []) } |
| 299 | + |
| 300 | + context "when remote and does not have multiple global sources" do |
| 301 | + before do |
| 302 | + subject.instance_variable_set(:@remote, true) |
| 303 | + allow(sources).to receive(:aggregate_global_source?).and_return(false) |
| 304 | + allow(sources).to receive(:non_global_rubygems_sources).and_return(non_global_rubygems_sources) |
| 305 | + end |
| 306 | + |
| 307 | + context "when all the scoped sources contain a dependency API" do |
| 308 | + let(:non_global_rubygems_sources) do |
| 309 | + [ |
| 310 | + double("non-global-source-0", :dependency_api_available? => true, :to_s => "a"), |
| 311 | + double("non-global-source-1", :dependency_api_available? => true, :to_s => "b"), |
| 312 | + ] |
| 313 | + end |
| 314 | + |
| 315 | + it "will not raise a warning" do |
| 316 | + expect(subject).not_to receive(:non_dependency_api_warning) |
| 317 | + |
| 318 | + expect(subject.send(:precompute_source_requirements_for_indirect_dependencies?)).to be_truthy |
| 319 | + end |
| 320 | + end |
| 321 | + |
| 322 | + context "when scoped sources do not contain a dependency API" do |
| 323 | + let(:non_global_rubygems_sources) do |
| 324 | + [ |
| 325 | + double("non-global-source-0", :dependency_api_available? => true, :to_s => "a"), |
| 326 | + double("non-global-source-1", :dependency_api_available? => false, :to_s => "b"), |
| 327 | + double("non-global-source-2", :dependency_api_available? => false, :to_s => "c"), |
| 328 | + ] |
| 329 | + end |
| 330 | + |
| 331 | + it "will raise a warning" do |
| 332 | + expect(Bundler.ui).to receive(:warn).with(<<-W.strip) |
| 333 | +Your Gemfile contains scoped sources that don't implement a dependency API, namely: |
| 334 | +
|
| 335 | + * b |
| 336 | + * c |
| 337 | +
|
| 338 | +Using the above gem servers may result in installing unexpected gems. To resolve this warning, make sure you use gem servers that implement dependency APIs, such as gemstash or geminabox gem servers. |
| 339 | + W |
| 340 | + |
| 341 | + expect(subject.send(:precompute_source_requirements_for_indirect_dependencies?)).to be_falsy |
| 342 | + end |
| 343 | + end |
| 344 | + end |
| 345 | + end |
| 346 | + |
292 | 347 | def mock_source_list |
293 | 348 | Class.new do |
294 | 349 | def all_sources |
|
0 commit comments