Skip to content

Commit c92d679

Browse files
mctofuDavid Rodriguez
and
David Rodriguez
committed
Better explain the test is also verifying the metadata
Co-authored-by: David Rodriguez <[email protected]>
1 parent bab09ee commit c92d679

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

npm_and_yarn/spec/dependabot/npm_and_yarn/update_checker_spec.rb

+10-10
Original file line numberDiff line numberDiff line change
@@ -1363,18 +1363,18 @@
13631363

13641364
# Dependency doesn't consider metadata as part of equality checks
13651365
# so this allows us to check that the metadata is updated in tests.
1366-
RSpec::Matchers.define :with_metadata do |expected|
1366+
RSpec::Matchers.define :including_metadata do |expected|
13671367
match do |actual|
13681368
actual == expected && actual.metadata == expected.metadata
13691369
end
13701370
end
13711371

1372-
def contain_exactly_with_metadata(*expected)
1373-
contain_exactly(*expected.map { |e| with_metadata(e) })
1372+
def contain_exactly_including_metadata(*expected)
1373+
contain_exactly(*expected.map { |e| including_metadata(e) })
13741374
end
13751375

1376-
def eq_with_metadata(expected_array)
1377-
eq(expected_array).and contain_exactly_with_metadata(*expected_array)
1376+
def eq_including_metadata(expected_array)
1377+
eq(expected_array).and contain_exactly_including_metadata(*expected_array)
13781378
end
13791379

13801380
context "for a security update for a locked transitive dependency" do
@@ -1401,7 +1401,7 @@ def eq_with_metadata(expected_array)
14011401

14021402
it "correctly updates the transitive dependency" do
14031403
expect(checker.send(:updated_dependencies_after_full_unlock)).
1404-
to eq_with_metadata([
1404+
to eq_including_metadata([
14051405
Dependabot::Dependency.new(
14061406
name: "@dependabot-fixtures/npm-transitive-dependency",
14071407
version: "1.0.1",
@@ -1443,7 +1443,7 @@ def eq_with_metadata(expected_array)
14431443
let(:registry_listing_url) { "https://registry.npmjs.org/transitive-dependency-locked-by-intermediate" }
14441444

14451445
it "correctly updates the transitive dependency" do
1446-
expect(checker.send(:updated_dependencies_after_full_unlock)).to eq_with_metadata([
1446+
expect(checker.send(:updated_dependencies_after_full_unlock)).to eq_including_metadata([
14471447
Dependabot::Dependency.new(
14481448
name: "@dependabot-fixtures/npm-transitive-dependency",
14491449
package_manager: "npm_and_yarn",
@@ -1470,7 +1470,7 @@ def eq_with_metadata(expected_array)
14701470
let(:registry_listing_url) { "https://registry.npmjs.org/transitive-dependency-locked-by-multiple" }
14711471

14721472
it "correctly updates the transitive dependency" do
1473-
expect(checker.send(:updated_dependencies_after_full_unlock)).to contain_exactly_with_metadata(
1473+
expect(checker.send(:updated_dependencies_after_full_unlock)).to contain_exactly_including_metadata(
14741474
Dependabot::Dependency.new(
14751475
name: "@dependabot-fixtures/npm-parent-dependency",
14761476
package_manager: "npm_and_yarn",
@@ -1566,7 +1566,7 @@ def eq_with_metadata(expected_array)
15661566
end
15671567

15681568
it "correctly updates the parent dependency and removes the transitive because removal is enabled" do
1569-
expect(checker.send(:updated_dependencies_after_full_unlock)).to contain_exactly_with_metadata(
1569+
expect(checker.send(:updated_dependencies_after_full_unlock)).to contain_exactly_including_metadata(
15701570
Dependabot::Dependency.new(
15711571
name: "@dependabot-fixtures/npm-transitive-dependency",
15721572
package_manager: "npm_and_yarn",
@@ -1628,7 +1628,7 @@ def eq_with_metadata(expected_array)
16281628
end
16291629

16301630
it "correctly updates the transitive dependency by unlocking the parent" do
1631-
expect(checker.send(:updated_dependencies_after_full_unlock)).to eq_with_metadata([
1631+
expect(checker.send(:updated_dependencies_after_full_unlock)).to eq_including_metadata([
16321632
Dependabot::Dependency.new(
16331633
name: "@dependabot-fixtures/npm-transitive-dependency-with-more-versions",
16341634
package_manager: "npm_and_yarn",

0 commit comments

Comments
 (0)