Skip to content
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

TICtxtWrd-grdl: Test Improvements, Context Wording, For the ecosystem: Gradle #9882

Merged
merged 7 commits into from
Jun 3, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
.to match_array(%w(../ganttproject ../biz.ganttproject.core))
end

context "declared across multiple lines" do
context "when the subprojects are declared across multiple lines" do
let(:fixture_name) { "multiline_settings.gradle" }

it "includes the additional declarations" do
Expand Down
10 changes: 5 additions & 5 deletions gradle/spec/dependabot/gradle/file_fetcher_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def stub_no_content_request(path)
stub_content_request("buildSrc/build.gradle?ref=sha", "contents_java_basic_buildfile.json")
end

context "implicitly included" do
context "when the buildSrc is implicitly included" do
before do
stub_content_request("?ref=sha", "contents_java_with_buildsrc.json")
end
Expand All @@ -144,7 +144,7 @@ def stub_no_content_request(path)
end
end

context "explicitly included" do
context "when the buildSrc is explicitly included" do
before do
stub_content_request("?ref=sha", "contents_java_with_buildsrc_and_settings.json")
stub_content_request("settings.gradle?ref=sha", "contents_java_settings_explicit_buildsrc.json")
Expand Down Expand Up @@ -252,7 +252,7 @@ def stub_no_content_request(path)
end
end

context "containing a script plugin" do
context "when a script plugin is present" do
before do
stub_content_request("?ref=sha", "contents_java_with_settings.json")
stub_content_request("settings.gradle?ref=sha", "contents_java_settings_1_included_build.json")
Expand All @@ -277,7 +277,7 @@ def stub_no_content_request(path)
end
end

context "only a settings.gradle" do
context "when only a settings.gradle is present" do
before do
stub_content_request("?ref=sha", "contents_java_only_settings.json")
stub_content_request("app?ref=sha", "contents_java_subproject.json")
Expand Down Expand Up @@ -361,7 +361,7 @@ def stub_no_content_request(path)
end
end

context "that can't be found" do
context "when the content can't be found" do
before do
stub_content_request("?ref=sha", "contents_java.json")
stub_request(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,24 +39,24 @@

its([:file]) { is_expected.to eq("build.gradle") }

context "and the property name has a `project.` prefix" do
context "when the property name has a `project.` prefix" do
let(:property_name) { "project.kotlin_version" }

its([:value]) { is_expected.to eq("1.1.4-3") }
its([:file]) { is_expected.to eq("build.gradle") }
end

context "and the property name has a `rootProject.` prefix" do
context "when the property name has a `rootProject.` prefix" do
let(:property_name) { "rootProject.kotlin_version" }

its([:value]) { is_expected.to eq("1.1.4-3") }
its([:file]) { is_expected.to eq("build.gradle") }
end

context "and tricky properties" do
context "when there are tricky properties" do
let(:buildfile_fixture_name) { "properties.gradle" }

context "and the property is declared with ext.name" do
context "when the property is declared with ext.name" do
let(:property_name) { "kotlin_version" }

its([:value]) { is_expected.to eq("1.2.61") }
Expand All @@ -66,7 +66,7 @@
end
end

context "and the property is declared in an ext block" do
context "when the property is declared in an ext block" do
let(:property_name) { "buildToolsVersion" }

its([:value]) { is_expected.to eq("27.0.3") }
Expand All @@ -75,7 +75,7 @@
is_expected.to eq("buildToolsVersion = '27.0.3'")
end

context "and the property name has already been set" do
context "when the property name has already been set" do
let(:buildfile_fixture_name) { "duplicate_property_name.gradle" }
let(:property_name) { "spek_version" }

Expand All @@ -87,7 +87,7 @@
end
end

context "and the property is preceded by a comment" do
context "when the property is preceded by a comment" do
# This is important because the declaration string must not include
# whitespace that will be different to when the FileUpdater uses it
# (i.e., before the comments are stripped out)
Expand All @@ -100,7 +100,7 @@
end
end

context "and the property is using findProperty syntax" do
context "when the property is using findProperty syntax" do
let(:property_name) { "findPropertyVersion" }

its([:value]) { is_expected.to eq("27.1.1") }
Expand All @@ -110,7 +110,7 @@
end
end

context "and the property is using hasProperty syntax" do
context "when the property is using hasProperty syntax" do
let(:property_name) { "hasPropertyVersion" }

its([:value]) { is_expected.to eq("27.1.1") }
Expand All @@ -122,13 +122,13 @@
end
end

context "and the property is commented out" do
context "when the property is commented out" do
let(:property_name) { "commentedVersion" }

it { is_expected.to be_nil }
end

context "and the property is declared within a namespace" do
context "when the property is declared within a namespace" do
let(:buildfile_fixture_name) { "properties_namespaced.gradle" }
let(:property_name) { "versions.okhttp" }

Expand All @@ -138,7 +138,7 @@
is_expected.to eq("okhttp : '3.12.1'")
end

context "and the property is using findProperty syntax" do
context "when the property is using findProperty syntax" do
let(:property_name) { "versions.findPropertyVersion" }

its([:value]) { is_expected.to eq("1.0.0") }
Expand All @@ -148,7 +148,7 @@
end
end

context "and the property is using hasProperty syntax" do
context "when the property is using hasProperty syntax" do
let(:property_name) { "versions.hasPropertyVersion" }

its([:value]) { is_expected.to eq("1.0.0") }
Expand Down Expand Up @@ -196,14 +196,14 @@
its([:value]) { is_expected.to eq("1.1.4-3") }
its([:file]) { is_expected.to eq("build.gradle") }

context "and the property name has a `project.` prefix" do
context "when the property name has a `project.` prefix" do
let(:property_name) { "project.kotlin_version" }

its([:value]) { is_expected.to eq("1.1.4-3") }
its([:file]) { is_expected.to eq("build.gradle") }
end

context "and the property name has a `rootProject.` prefix" do
context "when the property name has a `rootProject.` prefix" do
let(:property_name) { "rootProject.kotlin_version" }

its([:value]) { is_expected.to eq("1.1.4-3") }
Expand All @@ -214,14 +214,14 @@
let(:buildfile_fixture_name) { "basic_build.gradle" }
let(:callsite_fixture_name) { "single_property_build.gradle" }

context "and the property name has a `project.` prefix" do
context "when the property name has a `project.` prefix" do
let(:property_name) { "project.kotlin_version" }

its([:value]) { is_expected.to eq("1.1.4-3") }
its([:file]) { is_expected.to eq("myapp/build.gradle") }
end

context "and the property name has a `rootProject.` prefix" do
context "when the property name has a `rootProject.` prefix" do
let(:property_name) { "rootProject.kotlin_version" }

# We wouldn't normally expect this to be `nil` - it's more likely to
Expand All @@ -234,7 +234,7 @@
let(:dependency_files) { [callsite_buildfile] }
let(:callsite_fixture_name) { "single_property_build.gradle" }

context "and the property cannot be found" do
context "when the property cannot be found" do
let(:property_name) { "project.NotFoundProperty" }

it { is_expected.to be_nil }
Expand Down Expand Up @@ -264,22 +264,22 @@

its([:file]) { is_expected.to eq("build.gradle.kts") }

context "and the property name has a `project.` prefix" do
context "when the property name has a `project.` prefix" do
let(:property_name) { "project.kotlinVersion" }

its([:value]) { is_expected.to eq("1.2.61") }
its([:file]) { is_expected.to eq("build.gradle.kts") }
end

context "and the property name has a `rootProject.` prefix" do
context "when the property name has a `rootProject.` prefix" do
let(:property_name) { "rootProject.kotlinVersion" }

its([:value]) { is_expected.to eq("1.2.61") }
its([:file]) { is_expected.to eq("build.gradle.kts") }
end

context "and tricky properties" do
context "and the property is declared with extra[key] = value" do
context "when there are tricky properties" do
context "when the property is declared with extra[key] = value" do
let(:property_name) { "kotlinVersion" }

its([:value]) { is_expected.to eq("1.2.61") }
Expand All @@ -289,7 +289,7 @@
end
end

context "and the property is declared with extra.set(key, value)" do
context "when the property is declared with extra.set(key, value)" do
let(:property_name) { "javaVersion" }

its([:value]) { is_expected.to eq("11") }
Expand All @@ -299,7 +299,7 @@
end
end

context "and the property is declared in an extra.apply block" do
context "when the property is declared in an extra.apply block" do
let(:property_name) { "buildToolsVersion" }

its([:value]) { is_expected.to eq("27.0.3") }
Expand All @@ -309,7 +309,7 @@
end
end

context "and the property is preceded by a comment" do
context "when the property is preceded by a comment" do
# This is important because the declaration string must
# not include whitespace that will be different to when
# the FileUpdater uses it (i.e., before the comments
Expand All @@ -323,7 +323,7 @@
end
end

context "and the property is using findProperty syntax" do
context "when the property is using findProperty syntax" do
let(:property_name) { "findPropertyVersion" }

its([:value]) { is_expected.to eq("27.1.1") }
Expand All @@ -333,7 +333,7 @@
end
end

context "and the property is using hasProperty syntax" do
context "when the property is using hasProperty syntax" do
let(:property_name) { "hasPropertyVersion" }

its([:value]) { is_expected.to eq("27.1.1") }
Expand All @@ -345,13 +345,13 @@
end
end

context "and the property is commented out" do
context "when the property is commented out" do
let(:property_name) { "commentedVersion" }

it { is_expected.to be_nil }
end

context "and the property is declared within a namespace" do
context "when the property is declared within a namespace" do
let(:buildfile_fixture_name) { "root_build.gradle.kts" }
let(:property_name) { "versions.okhttp" }

Expand All @@ -361,7 +361,7 @@
is_expected.to eq('"okhttp" to "3.12.1"')
end

context "and the property is using findProperty syntax" do
context "when the property is using findProperty syntax" do
let(:property_name) { "versions.findPropertyVersion" }

its([:value]) { is_expected.to eq("1.0.0") }
Expand All @@ -373,7 +373,7 @@
end
end

context "and the property is using hasProperty syntax" do
context "when the property is using hasProperty syntax" do
let(:property_name) { "versions.hasPropertyVersion" }

its([:value]) { is_expected.to eq("1.0.0") }
Expand Down Expand Up @@ -420,14 +420,14 @@
its([:value]) { is_expected.to eq("1.2.61") }
its([:file]) { is_expected.to eq("build.gradle.kts") }

context "and the property name has a `project.` prefix" do
context "when the property name has a `project.` prefix" do
let(:property_name) { "project.kotlinVersion" }

its([:value]) { is_expected.to eq("1.2.61") }
its([:file]) { is_expected.to eq("build.gradle.kts") }
end

context "and the property name has a `rootProject.` prefix" do
context "when the property name has a `rootProject.` prefix" do
let(:property_name) { "rootProject.kotlinVersion" }

its([:value]) { is_expected.to eq("1.2.61") }
Expand All @@ -438,14 +438,14 @@
let(:buildfile_fixture_name) { "build.gradle.kts" }
let(:callsite_fixture_name) { "root_build.gradle.kts" }

context "and the property name has a `project.` prefix" do
context "when the property name has a `project.` prefix" do
let(:property_name) { "project.kotlinVersion" }

its([:value]) { is_expected.to eq("1.2.61") }
its([:file]) { is_expected.to eq("myapp/build.gradle.kts") }
end

context "and the property name has a `rootProject.` prefix" do
context "when the property name has a `rootProject.` prefix" do
let(:property_name) { "rootProject.kotlinVersion" }

# We wouldn't normally expect this to be `nil` - it's more likely
Expand All @@ -458,7 +458,7 @@
let(:dependency_files) { [callsite_buildfile] }
let(:callsite_fixture_name) { "build.gradle.kts" }

context "and the property cannot be found" do
context "when the property cannot be found" do
let(:property_name) { "project.NotFoundProperty" }

it { is_expected.to be_nil }
Expand Down
Loading
Loading