Skip to content

Commit

Permalink
TICtxtWrd-n:Test Improvements, Context Wording, for the ecosystem npm…
Browse files Browse the repository at this point in the history
… and yarn.
  • Loading branch information
“Thavachelvam committed May 24, 2024
1 parent 13bf811 commit c9e63f9
Show file tree
Hide file tree
Showing 20 changed files with 416 additions and 409 deletions.
1 change: 0 additions & 1 deletion .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ RSpec/ContextWording:
- 'gradle/**/*'
- 'hex/**/*'
- 'maven/**/*'
- 'npm_and_yarn/**/*'
- 'nuget/**/*'
- 'pub/**/*'
- 'python/**/*'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
project_dependency_files(project_name).find { |f| f.name == "package-lock.json" }
end

context "for a path dependency with no sub-deps" do
context "when dealing with a path dependency with no sub-deps" do
let(:project_name) { "npm6/path_dependency" }

it "builds an imitation path dependency" do
Expand All @@ -43,7 +43,7 @@
end
end

context "for a path dependency with sub-deps" do
context "when dealing with a path dependency with sub-deps" do
let(:project_name) { "npm6/path_dependency_subdeps" }
let(:dependency_name) { "other_package" }
let(:path) { "other_package" }
Expand All @@ -67,7 +67,7 @@
project_dependency_files(project_name).find { |f| f.name == "yarn.lock" }
end

context "for a path dependency with no sub-deps" do
context "when dealing with a path dependency with no sub-deps" do
let(:project_name) { "yarn/path_dependency" }

it "builds an imitation path dependency" do
Expand All @@ -79,15 +79,15 @@
end
end

context "that can't be parsed" do
context "when it can't be parsed" do
let(:project_name) { "yarn/unparseable" }

it "raises DependencyFileNotParseable" do
expect { dependency_file }.to raise_error(Dependabot::DependencyFileNotParseable)
end
end

context "for a path dependency with sub-deps" do
context "when dealing with a path dependency with sub-deps" do
let(:project_name) { "yarn/path_dependency_subdeps" }
let(:dependency_name) { "other_package" }
let(:path) { "other_package" }
Expand All @@ -109,7 +109,7 @@
end
end

context "for a symlinked dependency" do
context "when dealing with a symlinked dependency" do
let(:project_name) { "yarn/symlinked_dependency" }

it "builds an imitation path dependency" do
Expand Down
66 changes: 33 additions & 33 deletions npm_and_yarn/spec/dependabot/npm_and_yarn/file_fetcher_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
end
end

context "that has a blank file: in the package-lock" do
context "when it has a blank file: in the package-lock" do
before do
stub_request(:get, File.join(url, "package.json?ref=sha"))
.with(headers: { "Authorization" => "token token" })
Expand Down Expand Up @@ -150,7 +150,7 @@
.to include("package-lock.json")
end

context "that specifies no package-lock" do
context "when specifying no package-lock" do
before do
stub_request(:get, File.join(url, ".npmrc?ref=sha"))
.with(headers: { "Authorization" => "token token" })
Expand Down Expand Up @@ -200,7 +200,7 @@
)
end

context "that has an unfetchable path" do
context "when path is unfetchable" do
before do
stub_request(:get, File.join(url, "deps/etag/package.json?ref=sha"))
.with(headers: { "Authorization" => "token token" })
Expand Down Expand Up @@ -328,7 +328,7 @@
.to_return(status: 404)
end

context "and older than 5.4 lockfile format" do
context "when using older than 5.4 lockfile format" do
before do
stub_request(:get, File.join(url, "pnpm-lock.yaml?ref=sha"))
.with(headers: { "Authorization" => "token token" })
Expand All @@ -350,7 +350,7 @@
end
end

context "and 5.4 as lockfile format" do
context "when using 5.4 as lockfile format" do
before do
stub_request(:get, File.join(url, "pnpm-lock.yaml?ref=sha"))
.with(headers: { "Authorization" => "token token" })
Expand All @@ -373,7 +373,7 @@
end
end

context "and 6.0 as lockfile format" do
context "when using 6.0 as lockfile format" do
before do
stub_request(:get, File.join(url, "pnpm-lock.yaml?ref=sha"))
.with(headers: { "Authorization" => "token token" })
Expand All @@ -396,7 +396,7 @@
end
end

context "using double quotes to surround lockfileVersion" do
context "when using double quotes to surround lockfileVersion" do
before do
stub_request(:get, File.join(url, "pnpm-lock.yaml?ref=sha"))
.with(headers: { "Authorization" => "token token" })
Expand Down Expand Up @@ -561,7 +561,7 @@
end
end

context "that has a fetchable path" do
context "when path is fetchable" do
before do
stub_request(:get, File.join(url, "deps/etag/package.json?ref=sha"))
.with(headers: { "Authorization" => "token token" })
Expand All @@ -582,7 +582,7 @@
end
end

context "that is specified as a link" do
context "when it is specified as a link" do
before do
stub_request(:get, File.join(url, "package.json?ref=sha"))
.with(headers: { "Authorization" => "token token" })
Expand Down Expand Up @@ -652,7 +652,7 @@
end
end

context "that has an unfetchable tarball path dependency" do
context "when tarball path dependency is unfetchable" do
before do
stub_request(:get, File.join(url, "package.json?ref=sha"))
.with(headers: { "Authorization" => "token token" })
Expand Down Expand Up @@ -724,7 +724,7 @@
end
end

context "that has an unfetchable tar path dependency" do
context "when tar path dependency is unfetchable" do
before do
stub_request(:get, File.join(url, "package.json?ref=sha"))
.with(headers: { "Authorization" => "token token" })
Expand Down Expand Up @@ -754,7 +754,7 @@
end
end

context "that has an unfetchable path" do
context "when path is unfetchable" do
before do
stub_request(:get, File.join(url, "deps/etag/package.json?ref=sha"))
.with(headers: { "Authorization" => "token token" })
Expand Down Expand Up @@ -801,7 +801,7 @@
end
end

context "that only appears in the lockfile" do
context "when it only appears in the lockfile" do
before do
stub_request(:get, url + "?ref=sha")
.with(headers: { "Authorization" => "token token" })
Expand Down Expand Up @@ -850,7 +850,7 @@
)
end

context "that has a fetchable path" do
context "when paths are fetchable" do
before do
file_url = File.join(url, "mocks/sprintf-js/package.json?ref=sha")
stub_request(:get, file_url)
Expand All @@ -872,7 +872,7 @@
end
end

context "that has an unfetchable path" do
context "when paths are unfetchable" do
before do
file_url = File.join(url, "mocks/sprintf-js/package.json?ref=sha")
stub_request(:get, file_url)
Expand Down Expand Up @@ -950,7 +950,7 @@
)
end

context "that have fetchable paths" do
context "when paths are fetchable" do
before do
stub_request(:get, File.join(url, "packages?ref=sha"))
.with(headers: { "Authorization" => "token token" })
Expand Down Expand Up @@ -1043,7 +1043,7 @@
.to include("packages/package2/package.json")
end

context "and a deeply nested package" do
context "when dealing with a deeply nested package" do
before do
stub_request(
:get,
Expand Down Expand Up @@ -1166,7 +1166,7 @@
end
end

context "in a directory" do
context "when in a directory" do
let(:url) do
"https://api.github.com/repos/gocardless/bump/contents/etc"
end
Expand Down Expand Up @@ -1202,7 +1202,7 @@
end
end

context "that has an unfetchable path" do
context "when paths are unfetchable" do
before do
stub_request(:get, File.join(url, "packages?ref=sha"))
.with(headers: { "Authorization" => "token token" })
Expand Down Expand Up @@ -1289,7 +1289,7 @@
)
end

context "that have fetchable paths" do
context "when paths are fetchable" do
before do
stub_request(:get, File.join(url, "packages?ref=sha"))
.with(headers: { "Authorization" => "token token" })
Expand Down Expand Up @@ -1338,7 +1338,7 @@
expect(workspace_dep.type).to eq("file")
end

context "specified using './packages/*'" do
context "when specified using './packages/*'" do
before do
stub_request(:get, File.join(url, "package.json?ref=sha"))
.with(headers: { "Authorization" => "token token" })
Expand All @@ -1361,7 +1361,7 @@
end
end

context "specified using 'packages/*/*'" do
context "when specified using 'packages/*/*'" do
before do
stub_request(:get, File.join(url, "package.json?ref=sha"))
.with(headers: { "Authorization" => "token token" })
Expand Down Expand Up @@ -1566,19 +1566,19 @@
end
end

context "specified using 'packages/**'" do
context "when specified using 'packages/**'" do
let(:project) { "yarn/double_star_workspaces" }

it_behaves_like "fetching all files recursively"
end

context "specified using 'packages/**/*'" do
context "when specified using 'packages/**/*'" do
let(:project) { "yarn/double_star_single_star_workspaces" }

it_behaves_like "fetching all files recursively"
end

context "specified using a hash" do
context "when specified using a hash" do
before do
stub_request(:get, File.join(url, "package.json?ref=sha"))
.with(headers: { "Authorization" => "token token" })
Expand All @@ -1595,7 +1595,7 @@
.to include("packages/package2/package.json")
end

context "that excludes a workspace" do
context "when excluding a workspace" do
before do
stub_request(:get, File.join(url, "package.json?ref=sha"))
.with(headers: { "Authorization" => "token token" })
Expand Down Expand Up @@ -1629,7 +1629,7 @@
end
end

context "that uses nohoist" do
context "when using nohoist" do
before do
stub_request(:get, File.join(url, "package.json?ref=sha"))
.with(headers: { "Authorization" => "token token" })
Expand All @@ -1651,7 +1651,7 @@
end
end

context "specified with a top-level wildcard" do
context "when specified with a top-level wildcard" do
before do
stub_request(:get, File.join(url, "package.json?ref=sha"))
.with(headers: { "Authorization" => "token token" })
Expand Down Expand Up @@ -1713,7 +1713,7 @@
end
end

context "including an empty folder" do
context "when including an empty folder" do
before do
stub_request(
:get,
Expand All @@ -1729,7 +1729,7 @@
end
end

context "in a directory" do
context "when in a directory" do
let(:url) do
"https://api.github.com/repos/gocardless/bump/contents/etc"
end
Expand Down Expand Up @@ -1763,7 +1763,7 @@
.to include("packages/package2/package.json")
end

context "and an npmrc file in the parent directory" do
context "when dealing with an npmrc file in the parent directory" do
before do
stub_request(
:get,
Expand All @@ -1786,7 +1786,7 @@
end
end

context "that has an unfetchable path" do
context "when there is an unfetchable path" do
before do
stub_request(:get, File.join(url, "packages?ref=sha"))
.with(headers: { "Authorization" => "token token" })
Expand Down Expand Up @@ -1828,7 +1828,7 @@
.to_not include("other_package/package.json")
end

context "because one of the repos isn't fetchable" do
context "when one of the repos isn't fetchable" do
before do
stub_request(:get, File.join(url, "packages?ref=sha"))
.with(headers: { "Authorization" => "token token" })
Expand Down
Loading

0 comments on commit c9e63f9

Please sign in to comment.