-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Include detailed dependencies when gemfile and lockfile are conflicts #9332
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
hsbt
wants to merge
3
commits into
master
Choose a base branch
from
show-incorrect-dependencies-message
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,104 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| RSpec.describe Bundler::IncorrectLockfileDependencies do | ||
| describe "#message" do | ||
| let(:spec) do | ||
| double("LazySpecification", full_name: "rubocop-1.82.0") | ||
| end | ||
|
|
||
| context "without dependency details" do | ||
| subject { described_class.new(spec) } | ||
|
|
||
| it "provides a basic error message" do | ||
| expect(subject.message).to include("Bundler found incorrect dependencies in the lockfile for rubocop-1.82.0") | ||
| expect(subject.message).to include("Please run `bundle install` to regenerate the lockfile.") | ||
| end | ||
| end | ||
|
|
||
| context "with dependency details" do | ||
| let(:actual_dependencies) do | ||
| [ | ||
| Gem::Dependency.new("json", [">= 2.3", "< 4.0"]), | ||
| Gem::Dependency.new("parallel", ["~> 1.10"]), | ||
| Gem::Dependency.new("parser", [">= 3.3.0.2"]), | ||
| ] | ||
| end | ||
|
|
||
| let(:lockfile_dependencies) do | ||
| [ | ||
| Gem::Dependency.new("json", [">= 2.3", "< 3.0"]), | ||
| Gem::Dependency.new("parallel", ["~> 1.10"]), | ||
| Gem::Dependency.new("parser", [">= 3.2.0.0"]), | ||
| ] | ||
| end | ||
|
|
||
| subject { described_class.new(spec, actual_dependencies, lockfile_dependencies) } | ||
|
|
||
| it "provides a detailed error message showing the discrepancy" do | ||
| message = subject.message | ||
|
|
||
| expect(message).to include("Bundler found incorrect dependencies in the lockfile for rubocop-1.82.0") | ||
| expect(message).to include("The gemspec for rubocop-1.82.0 specifies the following dependencies:") | ||
| expect(message).to include("json (>= 2.3, < 4.0)") | ||
| expect(message).to include("parallel (~> 1.10)") | ||
| expect(message).to include("parser (>= 3.3.0.2)") | ||
| expect(message).to include("However, the lockfile has the following dependencies recorded:") | ||
| expect(message).to include("json (>= 2.3, < 3.0)") | ||
| expect(message).to include("parser (>= 3.2.0.0)") | ||
| expect(message).to include("This discrepancy may be caused by manually editing the lockfile.") | ||
| expect(message).to include("Please run `bundle install` to regenerate the lockfile with correct dependencies.") | ||
| end | ||
| end | ||
|
|
||
| context "when gemspec has dependencies but lockfile has none" do | ||
| let(:actual_dependencies) do | ||
| [ | ||
| Gem::Dependency.new("myrack-test", ["~> 1.0"]), | ||
| ] | ||
| end | ||
|
|
||
| let(:lockfile_dependencies) { [] } | ||
|
|
||
| subject { described_class.new(spec, actual_dependencies, lockfile_dependencies) } | ||
|
|
||
| it "shows that lockfile has no dependencies" do | ||
| message = subject.message | ||
|
|
||
| expect(message).to include("The gemspec for rubocop-1.82.0 specifies the following dependencies:") | ||
| expect(message).to include("myrack-test (~> 1.0)") | ||
| expect(message).to include("However, the lockfile has the following dependencies recorded:") | ||
| expect(message).to include("(none)") | ||
| end | ||
| end | ||
|
|
||
| context "when gemspec has no dependencies but lockfile has some" do | ||
| let(:actual_dependencies) { [] } | ||
|
|
||
| let(:lockfile_dependencies) do | ||
| [ | ||
| Gem::Dependency.new("unexpected", ["~> 1.0"]), | ||
| ] | ||
| end | ||
|
|
||
| subject { described_class.new(spec, actual_dependencies, lockfile_dependencies) } | ||
|
|
||
| it "shows that gemspec has no dependencies" do | ||
| message = subject.message | ||
|
|
||
| expect(message).to include("The gemspec for rubocop-1.82.0 specifies the following dependencies:") | ||
| expect(message).to include("(none)") | ||
| expect(message).to include("However, the lockfile has the following dependencies recorded:") | ||
| expect(message).to include("unexpected (~> 1.0)") | ||
| end | ||
| end | ||
| end | ||
|
|
||
| describe "#status_code" do | ||
| let(:spec) { double("LazySpecification", full_name: "test-1.0.0") } | ||
| subject { described_class.new(spec) } | ||
|
|
||
| it "returns 41" do | ||
| expect(subject.status_code).to eq(41) | ||
| end | ||
| end | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.