Skip to content

Commit

Permalink
Merge pull request #3396 from dependabot/feelepxyz/use-fixture-helpers
Browse files Browse the repository at this point in the history
Bundler: Use project fixture helpers in specs
  • Loading branch information
feelepxyz authored Mar 29, 2021
2 parents 75f9803 + a1b1bd2 commit a7fd3a3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@
options: { bundler_2_available: bundler_2_available? }
)
end
let(:dependency_files) { [gemfile, lockfile] }
let(:dependency_files) do
bundler_project_dependency_files("subdep_blocked_by_subdep")
end

let(:dependency) do
Dependabot::Dependency.new(
Expand All @@ -36,15 +38,6 @@
let(:current_version) { "1.0.1" }
let(:target_version) { "2.0.0" }

let(:gemfile) do
Dependabot::DependencyFile.new(content: gemfile_body, name: "Gemfile")
end
let(:lockfile) do
Dependabot::DependencyFile.new(content: lockfile_body, name: "Gemfile.lock")
end
let(:gemfile_body) { fixture("projects", "bundler1", "subdep_blocked_by_subdep", "Gemfile") }
let(:lockfile_body) { fixture("projects", "bundler1", "subdep_blocked_by_subdep", "Gemfile.lock") }

describe "#conflicting_dependencies" do
subject(:conflicting_dependencies) do
resolver.conflicting_dependencies(
Expand All @@ -68,6 +61,7 @@

context "with no blocking dependencies" do
let(:target_version) { "1.5.0" }

it "returns an empty array" do
expect(conflicting_dependencies).to match_array([])
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
options: { bundler_2_available: bundler_2_available? }
)
end
let(:dependency_files) { [gemfile, lockfile] }
let(:dependency_files) { bundler_project_dependency_files("gemfile") }

let(:dependency) do
Dependabot::Dependency.new(
Expand Down Expand Up @@ -55,21 +55,11 @@
}]
end

let(:gemfile) do
Dependabot::DependencyFile.new(content: gemfile_body, name: "Gemfile")
end
let(:lockfile) do
Dependabot::DependencyFile.new(content: lockfile_body, name: "Gemfile.lock")
end

describe "#updated_dependencies" do
subject(:updated_dependencies) { updater.updated_dependencies }

context "when updating the dependency that requires the other" do
let(:gemfile_body) { fixture("projects", "bundler1", "version_conflict", "Gemfile") }
let(:lockfile_body) do
fixture("projects", "bundler1", "version_conflict", "Gemfile.lock")
end
let(:dependency_files) { bundler_project_dependency_files("version_conflict") }
let(:target_version) { "3.6.0" }
let(:dependency_name) { "rspec-mocks" }
let(:requirements) do
Expand Down Expand Up @@ -114,10 +104,7 @@
end

context "when updating the dependency that is required by the other" do
let(:gemfile_body) { fixture("projects", "bundler1", "version_conflict", "Gemfile") }
let(:lockfile_body) do
fixture("projects", "bundler1", "version_conflict", "Gemfile.lock")
end
let(:dependency_files) { bundler_project_dependency_files("version_conflict") }
let(:target_version) { "3.6.0" }
let(:dependency_name) { "rspec-support" }
let(:requirements) do
Expand Down Expand Up @@ -162,10 +149,7 @@
end

context "when two dependencies require the same subdependency" do
let(:gemfile_body) { fixture("projects", "bundler1", "version_conflict_mutual_sub", "Gemfile") }
let(:lockfile_body) do
fixture("projects", "bundler1", "version_conflict_mutual_sub", "Gemfile.lock")
end
let(:dependency_files) { bundler_project_dependency_files("version_conflict_mutual_sub") }

let(:dependency_name) { "rspec-mocks" }
let(:target_version) { "3.6.0" }
Expand Down Expand Up @@ -211,10 +195,7 @@
end

context "when another dependency would need to be downgraded" do
let(:gemfile_body) { fixture("projects", "bundler1", "subdep_blocked_by_subdep", "Gemfile") }
let(:lockfile_body) do
fixture("projects", "bundler1", "subdep_blocked_by_subdep", "Gemfile.lock")
end
let(:dependency_files) { bundler_project_dependency_files("subdep_blocked_by_subdep") }
let(:target_version) { "2.0.0" }
let(:dependency_name) { "dummy-pkg-a" }

Expand All @@ -225,10 +206,7 @@
end

context "when the ruby version would need to change" do
let(:gemfile_body) { fixture("projects", "bundler1", "legacy_ruby", "Gemfile") }
let(:lockfile_body) do
fixture("projects", "bundler1", "legacy_ruby", "Gemfile.lock")
end
let(:dependency_files) { bundler_project_dependency_files("legacy_ruby") }
let(:target_version) { "2.0.5" }
let(:dependency_name) { "public_suffix" }

Expand Down

0 comments on commit a7fd3a3

Please sign in to comment.