Skip to content

Commit

Permalink
TICtxtWrd-maven: Test Improvements, Context Wording, ecosystem maven.
Browse files Browse the repository at this point in the history
  • Loading branch information
鈥淭havachelvam authored and thavaahariharangit committed May 24, 2024
1 parent 63e6282 commit 8ac0bb5
Show file tree
Hide file tree
Showing 16 changed files with 155 additions and 156 deletions.
1 change: 0 additions & 1 deletion .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ RSpec/ContextWording:
- 'go_modules/**/*'
- 'gradle/**/*'
- 'hex/**/*'
- 'maven/**/*'
- 'npm_and_yarn/**/*'
- 'nuget/**/*'
- 'pub/**/*'
Expand Down
6 changes: 3 additions & 3 deletions maven/spec/dependabot/maven/file_fetcher_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@
)
end

context "that uses submodules" do
context "when that uses submodules" do
before do
stub_request(:get, File.join(url, "util/pom.xml?ref=sha"))
.with(headers: { "Authorization" => "token token" })
Expand Down Expand Up @@ -233,7 +233,7 @@
end
end

context "where the repo for a child module is missing" do
context "when the repo for a child module is missing" do
before do
stub_request(:get, File.join(url, "util/pom.xml?ref=sha"))
.with(headers: { "Authorization" => "token token" })
Expand Down Expand Up @@ -337,7 +337,7 @@
end
end

context "where multiple poms require the same file" do
context "when multiple poms require the same file" do
before do
stub_request(:get, File.join(url, "util/legacy/pom.xml?ref=sha"))
.with(headers: { "Authorization" => "token token" })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
expect(fetch_remote_parent_pom.content).to include("snapshot")
end

context "but the response is malformed" do
context "when the response is malformed" do
before do
stub_request(:get, "https://repo.maven.apache.org/maven2/" \
"org/springframework/boot/" \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,21 @@

its([:value]) { is_expected.to eq("4.3.12.RELEASE") }

context "and the property is an attribute on the project" do
context "when the property is an attribute on the project" do
let(:base_pom_fixture_name) { "project_version_pom.xml" }
let(:property_name) { "project.version" }

its([:value]) { is_expected.to eq("0.0.2-RELEASE") }
end

context "and the property name starts with 'project' but not an attribute of the project" do
context "when the property name starts with 'project' but not an attribute of the project" do
let(:base_pom_fixture_name) { "property_name_starts_with_project_pom.xml" }
let(:property_name) { "project.dependency.spring-boot.version" }

its([:value]) { is_expected.to eq("2.2.1.RELEASE") }
end

context "and the property is within a profile" do
context "when the property is within a profile" do
let(:base_pom_fixture_name) { "profile_property_pom.xml" }

its([:value]) { is_expected.to eq("4.3.12.RELEASE") }
Expand All @@ -58,14 +58,14 @@
specify { expect { property_details }.to_not raise_error }
end

context "and in case of duplicate tags then read the latest" do
context "when there are duplicate tags then read the latest" do
let(:base_pom_fixture_name) { "property_pom_duplicate_tags.xml" }
let(:property_name) { "jmh.version" }

its([:value]) { is_expected.to eq("1.2.7") }
end

context "and the latest tag is pointing to self then raise the error" do
context "when the latest tag is pointing to self then raise the error" do
let(:base_pom_fixture_name) { "property_pom_duplicate_tags.xml" }
let(:property_name) { "dozer.version" }

Expand All @@ -76,14 +76,14 @@
end
end

context "and the latest tag is pointing to another tag, then get the value of that tag" do
context "when the latest tag is pointing to another tag, then get the value of that tag" do
let(:base_pom_fixture_name) { "property_pom_duplicate_tags.xml" }
let(:property_name) { "orika.version" }

its([:value]) { is_expected.to eq("1.2.7") }
end

context "and malformed expression should be treated as regular value." do
context "when malformed expression should be treated as regular value." do
let(:base_pom_fixture_name) { "property_pom_duplicate_tags.xml" }
let(:property_name) { "lombok.version" }

Expand Down Expand Up @@ -112,12 +112,12 @@

its([:value]) { is_expected.to eq("2.5.6") }

context "and the property name needs careful manipulation" do
context "when the property name needs careful manipulation" do
let(:property_name) { "spring.version.2.2" }

its([:value]) { is_expected.to eq("2.2.1") }

context "(case2)" do
context "when that is (case2)" do
let(:property_name) { "jta-api-1.2-version" }

its([:value]) { is_expected.to eq("1.2.1") }
Expand Down Expand Up @@ -154,7 +154,7 @@

its([:value]) { is_expected.to eq("2.7") }

context "that can't be found" do
context "when that can't be found" do
before do
stub_request(:get, struts_apps_maven_url)
.to_return(status: 404, body: "")
Expand All @@ -163,19 +163,19 @@
it { is_expected.to be_nil }
end

context "that specifies a version range (so can't be fetched)" do
context "when that specifies a version range (so can't be fetched)" do
let(:base_pom_fixture_name) { "remote_parent_pom_with_range.xml" }

it { is_expected.to be_nil }
end

context "that uses properties so can't be fetched" do
context "when that uses properties so can't be fetched" do
let(:base_pom_fixture_name) { "remote_parent_pom_with_props.xml" }

it { is_expected.to be_nil }
end

context "that is a custom repo" do
context "when that is a custom repo" do
let(:base_pom_fixture_name) { "custom_repositories_child_pom.xml" }

let(:scala_plugins_maven_url) do
Expand Down
22 changes: 11 additions & 11 deletions maven/spec/dependabot/maven/file_parser/repositories_finder_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
expect(finder.central_repo_url).to eq("https://repo.maven.apache.org/maven2")
end

context "if replaces-base is present" do
context "when replaces-base is present" do
let(:credentials) do
[Dependabot::Credential.new({
"type" => "maven_repository",
Expand Down Expand Up @@ -129,7 +129,7 @@
)
end

context "that overwrites central" do
context "when that overwrites central" do
let(:base_pom_fixture_name) { "overwrite_central_pom.xml" }

it "does not include central" do
Expand Down Expand Up @@ -161,7 +161,7 @@
end
end

context "that use properties" do
context "when that use properties" do
let(:base_pom_fixture_name) { "property_repo_pom.xml" }

it "handles the property interpolation" do
Expand All @@ -180,7 +180,7 @@
end
end

context "in the parent POM" do
context "when that is in the parent POM" do
let(:dependency_files) { [base_pom, child_pom] }
let(:child_pom) do
Dependabot::DependencyFile.new(
Expand All @@ -190,7 +190,7 @@
end
let(:child_pom_fixture_name) { "custom_repositories_child_pom.xml" }

context "checking the parent's repositories" do
context "when checking the parent's repositories" do
it "doesn't include the declarations from the child" do
expect(repository_urls).to eq(
%w(
Expand All @@ -203,7 +203,7 @@
end
end

context "checking the child's repositories" do
context "when checking the child's repositories" do
let(:pom) { child_pom }

it "includes the declarations from the parent and the child" do
Expand Down Expand Up @@ -246,7 +246,7 @@
"maven-scala-plugin-2.15.2.pom"
end

context "but specified a range of versions so can't be" do
context "when specified a range of versions so can't be" do
let(:child_pom_fixture_name) do
"custom_repositories_child_pom_range.xml"
end
Expand All @@ -261,7 +261,7 @@
end
end

context "that uses properties so can't be fetched" do
context "when that uses properties so can't be fetched" do
let(:child_pom_fixture_name) do
"custom_repositories_child_pom_with_props.xml"
end
Expand All @@ -276,7 +276,7 @@
end
end

context "from the central repo" do
context "when that is the central repo" do
before do
stub_request(:get, central_url)
.to_return(status: 200, body: base_pom.content)
Expand Down Expand Up @@ -304,7 +304,7 @@
expect(WebMock).to have_requested(:get, custom_url).once
end

context "and can't be found" do
context "when that can't be found" do
before do
stub_request(:get, central_url)
.to_return(status: 200, body: "some rubbish")
Expand All @@ -323,7 +323,7 @@
end
end

context "from the custom repo" do
context "when that is from the custom repo" do
before do
stub_request(:get, central_url)
.to_return(status: 200, body: "some rubbish")
Expand Down
Loading

0 comments on commit 8ac0bb5

Please sign in to comment.