|
474 | 474 | expect(the_bundle).to include_gems("my-private-gem 1.0") |
475 | 475 | end |
476 | 476 |
|
477 | | - it "throws a warning if a gem is added once in Gemfile and also inside a gemspec as a development dependency, with different requirements" do |
| 477 | + it "does not warn if a gem is added once in Gemfile and also inside a gemspec as a development dependency, with compatible requirements" do |
478 | 478 | build_lib "my-gem", path: bundled_app do |s| |
479 | 479 | s.add_development_dependency "rubocop", "~> 1.36.0" |
480 | 480 | end |
|
494 | 494 |
|
495 | 495 | bundle :install |
496 | 496 |
|
497 | | - expect(err).to include("A gemspec development dependency (rubocop, ~> 1.36.0) is being overridden by a Gemfile dependency (rubocop, >= 0).") |
498 | | - expect(err).to include("This behaviour may change in the future. Please remove either of them, or make sure they both have the same requirement") |
| 497 | + expect(err).to be_empty |
| 498 | + |
| 499 | + expect(the_bundle).to include_gems("rubocop 1.36.0") |
| 500 | + end |
| 501 | + |
| 502 | + it "raises an error if a gem is added once in Gemfile and also inside a gemspec as a development dependency, with incompatible requirements" do |
| 503 | + build_lib "my-gem", path: bundled_app do |s| |
| 504 | + s.add_development_dependency "rubocop", "~> 1.36.0" |
| 505 | + end |
| 506 | + |
| 507 | + build_repo4 do |
| 508 | + build_gem "rubocop", "1.36.0" |
| 509 | + build_gem "rubocop", "1.37.1" |
| 510 | + end |
| 511 | + |
| 512 | + gemfile <<~G |
| 513 | + source "https://gem.repo4" |
| 514 | +
|
| 515 | + gemspec |
| 516 | +
|
| 517 | + gem "rubocop", "~> 1.37.0", group: :development |
| 518 | + G |
499 | 519 |
|
500 | | - # This is not the best behavior I believe, it would be better if both |
501 | | - # requirements are considered if they are compatible, and a version |
502 | | - # satisfying both is chosen. But not sure about changing it right now, so |
503 | | - # I went with a warning for the time being. |
504 | | - expect(the_bundle).to include_gems("rubocop 1.37.1") |
| 520 | + bundle :install, raise_on_error: false |
| 521 | + |
| 522 | + expect(err).to include("The rubocop dependency has conflicting requirements in Gemfile (~> 1.37.0) and gemspec (~> 1.36.0)") |
505 | 523 | end |
506 | 524 |
|
507 | 525 | it "includes the gem without warning if two gemspecs add it with the same requirement" do |
|
590 | 608 | expect(err).to include("Two gemspec development dependencies have conflicting requirements on the same gem: rubocop (~> 1.36.0) and rubocop (~> 2.0). Bundler cannot continue.") |
591 | 609 | end |
592 | 610 |
|
593 | | - it "warns when a Gemfile dependency is overriding a gemspec development dependency, with different requirements" do |
594 | | - build_lib "my-gem", path: bundled_app do |s| |
595 | | - s.add_development_dependency "rails", ">= 5" |
596 | | - end |
597 | | - |
598 | | - build_repo4 do |
599 | | - build_gem "rails", "7.0.8" |
600 | | - end |
601 | | - |
602 | | - gemfile <<~G |
603 | | - source "https://gem.repo4" |
604 | | -
|
605 | | - gem "rails", "~> 7.0.8" |
606 | | -
|
607 | | - gemspec |
608 | | - G |
609 | | - |
610 | | - bundle :install |
611 | | - |
612 | | - expect(err).to include("A gemspec development dependency (rails, >= 5) is being overridden by a Gemfile dependency (rails, ~> 7.0.8).") |
613 | | - expect(err).to include("This behaviour may change in the future. Please remove either of them, or make sure they both have the same requirement") |
614 | | - |
615 | | - # This is not the best behavior I believe, it would be better if both |
616 | | - # requirements are considered if they are compatible, and a version |
617 | | - # satisfying both is chosen. But not sure about changing it right now, so |
618 | | - # I went with a warning for the time being. |
619 | | - expect(the_bundle).to include_gems("rails 7.0.8") |
620 | | - end |
621 | | - |
622 | 611 | it "does not warn if a gem is added once in Gemfile and also inside a gemspec as a development dependency, with same requirements, and different sources" do |
623 | 612 | build_lib "my-gem", path: bundled_app do |s| |
624 | 613 | s.add_development_dependency "activesupport" |
|
0 commit comments