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-Cargo: Test Improvement, Context Wording, ecosystem cargo. #9768

Merged
merged 1 commit into from
May 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ RSpec/BeforeAfterAll:
# Prefixes: when, with, without
RSpec/ContextWording:
Exclude:
- 'cargo/**/*'
- 'common/**/*'
- 'composer/**/*'
- 'devcontainers/**/*'
Expand Down
26 changes: 13 additions & 13 deletions cargo/spec/dependabot/cargo/file_fetcher_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@
fixture("github", "contents_cargo_manifest_path_deps.json")
end

context "that is fetchable" do
context "when the workspace is fetchable" do
before do
stub_request(:get, url + "src/s3/Cargo.toml?ref=sha")
.with(headers: { "Authorization" => "token token" })
Expand Down Expand Up @@ -295,7 +295,7 @@
end
end

context "for a target dependency" do
context "when dealing with a target dependency" do
let(:parent_fixture) do
fixture(
"github",
Expand All @@ -309,7 +309,7 @@
end
end

context "for a replacement source" do
context "when dealing with a replacement source" do
let(:parent_fixture) do
fixture("github", "contents_cargo_manifest_replacement_path.json")
end
Expand All @@ -320,7 +320,7 @@
end
end

context "for a patched source" do
context "when dealing with a patched source" do
let(:parent_fixture) do
fixture("github", "contents_cargo_manifest_patched_path.json")
end
Expand Down Expand Up @@ -379,7 +379,7 @@
end
end

context "and includes another path dependency" do
context "when including another path dependency" do
let(:path_dep_fixture) do
fixture("github", "contents_cargo_manifest_path_deps.json")
end
Expand All @@ -403,7 +403,7 @@
end
end

context "that is not fetchable" do
context "when the workspace is not fetchable" do
before do
stub_request(:get, url + "src/s3/Cargo.toml?ref=sha")
.with(headers: { "Authorization" => "token token" })
Expand All @@ -423,7 +423,7 @@
end
end

context "for a replacement source" do
context "when dealing with a replacement source" do
let(:parent_fixture) do
fixture("github", "contents_cargo_manifest_replacement_path.json")
end
Expand Down Expand Up @@ -478,7 +478,7 @@
fixture("github", "contents_cargo_manifest_workspace_root.json")
end

context "that is fetchable" do
context "when the workspace is fetchable" do
before do
stub_request(:get, url + "lib/sub_crate/Cargo.toml?ref=sha")
.with(headers: { "Authorization" => "token token" })
Expand All @@ -493,7 +493,7 @@
.to match_array(%w(Cargo.toml .cargo/config.toml lib/sub_crate/Cargo.toml))
end

context "and specifies the dependency implicitly" do
context "when specifying the dependency implicitly" do
let(:parent_fixture) do
fixture("github", "contents_cargo_manifest_workspace_implicit.json")
end
Expand All @@ -511,7 +511,7 @@
end
end

context "and specifies the dependency as a path dependency, too" do
context "when specifying the dependency as a path dependency as well" do
let(:parent_fixture) do
fixture(
"github",
Expand All @@ -528,7 +528,7 @@
end
end

context "that is not fetchable" do
context "when the workspace is not fetchable" do
before do
stub_request(:get, url + "lib/sub_crate/Cargo.toml?ref=sha")
.with(headers: { "Authorization" => "token token" })
Expand All @@ -548,7 +548,7 @@
end
end

context "that is in a submodule" do
context "when the project is in a submodule" do
before do
# This file doesn't exist because sub_crate is a submodule, so returns a 404
stub_request(:get, url + "lib/sub_crate/Cargo.toml?ref=sha")
Expand Down Expand Up @@ -577,7 +577,7 @@
end
end

context "that specifies a directory of packages" do
context "when specifying a directory of packages" do
let(:parent_fixture) do
fixture("github", "contents_cargo_manifest_workspace_root_glob.json")
end
Expand Down
8 changes: 4 additions & 4 deletions cargo/spec/dependabot/cargo/file_parser_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
end
end

context "which is part of a workspace but not the root" do
context "when the project is part of a workspace but not the root" do
let(:manifest_fixture_name) { "workspace_child" }

it "raises a helpful error" do
Expand Down Expand Up @@ -521,7 +521,7 @@
end
end

context "that is unparseable" do
context "when the input is unparseable" do
let(:manifest_fixture_name) { "unparseable" }

it "raises a DependencyFileNotParseable error" do
Expand All @@ -532,7 +532,7 @@
end
end

context "that have value overwrite issues" do
context "when there are value overwrite issues" do
let(:manifest_fixture_name) { "unparseable_value_overwrite" }

it "raises a DependencyFileNotParseable error" do
Expand Down Expand Up @@ -838,7 +838,7 @@
it { is_expected.to eq([]) }
end

context "that is unparseable" do
context "when the input is unparseable" do
let(:lockfile_fixture_name) { "unparseable" }

it "raises a DependencyFileNotParseable error" do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
end
end

context "because an existing requirement is no good" do
context "when an existing requirement is not sufficient" do
let(:dependency_version) { "0.1.38" }
let(:requirements) do
[{ file: "Cargo.toml", requirement: "0.3.20", groups: [], source: nil }]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
describe "#updated_manifest_content" do
subject(:updated_manifest_content) { updater.updated_manifest_content }

context "if no files have changed" do
context "when no files have changed" do
it { is_expected.to eq(manifest.content) }
end

Expand Down Expand Up @@ -245,7 +245,7 @@
}]
end

context "that is a build dependency" do
context "when dealing with a build dependency" do
let(:manifest_fixture_name) { "feature_build_dependency" }
let(:requirements) do
[{
Expand Down
2 changes: 1 addition & 1 deletion cargo/spec/dependabot/cargo/file_updater_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
context "without a lockfile" do
let(:files) { [manifest] }

context "if no files have changed" do
context "when no files have changed" do
it "raises a helpful error" do
expect { updater.updated_dependency_files }
.to raise_error("No files changed!")
Expand Down
4 changes: 2 additions & 2 deletions cargo/spec/dependabot/cargo/metadata_finder_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,15 @@
it { is_expected.to eq("https://github.com/rust-lang-nursery/bitflags") }
end

context "for a git source" do
context "when dealing with a git source" do
let(:crates_response) { nil }
let(:dependency_source) do
{ type: "git", url: "https://github.com/my_fork/bitflags" }
end

it { is_expected.to eq("https://github.com/my_fork/bitflags") }

context "that doesn't match a supported source" do
context "when it doesn't match a supported source" do
let(:dependency_source) do
{ type: "git", url: "https://example.com/my_fork/bitflags" }
end
Expand Down
18 changes: 9 additions & 9 deletions cargo/spec/dependabot/cargo/requirement_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
let(:requirement_string) { "1.1.*" }
it { is_expected.to eq(described_class.new("~> 1.1.0")) }

context "prefixed with a caret" do
context "when prefixed with a caret" do
let(:requirement_string) { "^1.1.*" }
it { is_expected.to eq(described_class.new("~> 1.1.0")) }
end
Expand All @@ -59,37 +59,37 @@
end

context "with a caret version" do
context "specified to 3 dp" do
context "when specified to 3 dp" do
let(:requirement_string) { "^1.2.3" }
it { is_expected.to eq(described_class.new(">= 1.2.3", "< 2.0.0")) }

context "with a zero major" do
let(:requirement_string) { "^0.2.3" }
it { is_expected.to eq(described_class.new(">= 0.2.3", "< 0.3.0")) }

context "and a zero minor" do
context "when a zero minor is present" do
let(:requirement_string) { "^0.0.3" }
it { is_expected.to eq(described_class.new(">= 0.0.3", "< 0.0.4")) }
end
end
end

context "specified to 2 dp" do
context "when specified to 2 dp" do
let(:requirement_string) { "^1.2" }
it { is_expected.to eq(described_class.new(">= 1.2", "< 2.0")) }

context "with a zero major" do
let(:requirement_string) { "^0.2" }
it { is_expected.to eq(described_class.new(">= 0.2", "< 0.3")) }

context "and a zero minor" do
context "when a zero minor is present" do
let(:requirement_string) { "^0.0" }
it { is_expected.to eq(described_class.new(">= 0.0", "< 0.1")) }
end
end
end

context "specified to 1 dp" do
context "when specified to 1 dp" do
let(:requirement_string) { "^1" }
it { is_expected.to eq(described_class.new(">= 1", "< 2")) }

Expand All @@ -101,17 +101,17 @@
end

context "with a ~ version" do
context "specified to 3 dp" do
context "when specified to 3 dp" do
let(:requirement_string) { "~1.5.1" }
it { is_expected.to eq(described_class.new("~> 1.5.1")) }
end

context "specified to 2 dp" do
context "when specified to 2 dp" do
let(:requirement_string) { "~1.5" }
it { is_expected.to eq(described_class.new("~> 1.5.0")) }
end

context "specified to 1 dp" do
context "when specified to 1 dp" do
let(:requirement_string) { "~1" }
it { is_expected.to eq(described_class.new("~> 1.0")) }
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
.to include('regex = ">= 0.1.41"')
end

context "the a target-specific dependency" do
context "when dealing with a target-specific dependency" do
let(:manifest_fixture_name) { "target_dependency" }
let(:lockfile_fixture_name) { "target_dependency" }
let(:dependency_name) { "time" }
Expand Down Expand Up @@ -158,15 +158,15 @@
.to include('regex = ">= 0.1.41"')
end

context "and a latest_allowable_version" do
context "when a latest_allowable_version is present" do
let(:latest_allowable_version) { Gem::Version.new("1.6.0") }

it "updates the requirement" do
expect(prepared_manifest_file.content)
.to include('regex = ">= 0.1.41, <= 1.6.0"')
end

context "that is lower than the current lower bound" do
context "when the value is lower than the current lower bound" do
let(:latest_allowable_version) { Gem::Version.new("0.1.0") }

it "updates the requirement" do
Expand Down Expand Up @@ -224,7 +224,7 @@
.to include('version = ">= 1.0.0"')
end

context "using ssh" do
context "when using ssh" do
let(:manifest_fixture_name) { "git_dependency_ssh" }
let(:lockfile_fixture_name) { "git_dependency_ssh" }

Expand Down
Loading
Loading