Skip to content

Commit

Permalink
TICtxtWrd-cmn: Test Improvements, Context Wording, ecosystem common. (#…
Browse files Browse the repository at this point in the history
…9856)

* TICtxtWrd-common: Test Improvement, Context Wording, for ecosystem common.

* TICtxtWrd-cmn: Test Improvements, Context Wording, ecosystem common.

* TICtxtWrd-common: Updating as per review comments.

---------

Co-authored-by: “Thavachelvam <“thavaahariharangit@git.com”>
  • Loading branch information
thavaahariharangit and “Thavachelvam authored May 30, 2024
1 parent 55febaf commit 3982be4
Show file tree
Hide file tree
Showing 41 changed files with 350 additions and 350 deletions.
8 changes: 4 additions & 4 deletions common/spec/dependabot/clients/azure_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@
end

describe "#get" do
context "Using auth headers" do
context "when using auth headers" do
token = ":test_token"
encoded_token = Base64.encode64(":test_token").delete("\n")
bearer_token = "test_token"
Expand Down Expand Up @@ -418,8 +418,8 @@
include_examples "#get using auth headers", bearer_token_data
end

context "Retries" do
context "for GET" do
context "when dealing with Retries" do
context "when dealing with GET" do
it "with failure count <= max_retries" do
# Request succeeds (200) on second attempt.
stub_request(:get, base_url)
Expand All @@ -440,7 +440,7 @@
end
end

context "for POST" do
context "when dealing with POST" do
before do
@request_body = "request body"
end
Expand Down
10 changes: 5 additions & 5 deletions common/spec/dependabot/clients/bitbucket_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
let(:default_reviewers_url) { api_base_url + repo + "/default-reviewers?pagelen=100&fields=values.uuid,next" }
let(:pull_request_url) { api_base_url + repo + "/pullrequests" }

context "create pull request successfully" do
context "when a pull request created successfully" do
before do
stub_request(:get, default_reviewers_url)
.with(headers: { "Authorization" => "Bearer #{access_token}" })
Expand Down Expand Up @@ -137,7 +137,7 @@
let(:status_params) { "?status=OPEN&status=MERGED&status=DECLINED&status=SUPERSEDED" }
let(:default_pull_requests_url) { api_base_url + repo + "/pullrequests" + status_params }

context "no pull requests found with matching source and target branch" do
context "when no pull requests found with matching source and target branch" do
before do
stub_request(:get, default_pull_requests_url)
.with(headers: { "Authorization" => "Bearer #{access_token}" })
Expand All @@ -149,7 +149,7 @@
it { is_expected.to eq([]) }
end

context "pull request found with matching source and target branch" do
context "when pull request found with matching source and target branch" do
before do
stub_request(:get, default_pull_requests_url)
.with(headers: { "Authorization" => "Bearer #{access_token}" })
Expand Down Expand Up @@ -183,7 +183,7 @@
}
end

context "only open pull requests with matching source and target branch" do
context "when only open pull requests match source and target branch" do
subject(:pull_requests) do
client.pull_requests(repo, "source_branch", "target_branch", %w(OPEN))
end
Expand Down Expand Up @@ -223,7 +223,7 @@
}
end

context "open pull requests where matching target branch" do
context "when open pull requests match target branch" do
subject(:pull_requests) do
client.pull_requests(repo, nil, "target_branch", %w(OPEN))
end
Expand Down
2 changes: 1 addition & 1 deletion common/spec/dependabot/config/update_config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@
expect(ignored_versions).to eq([">= 0"])
end

context "and ignore condition that must be normalized" do
context "when an ignore condition that must be normalized" do
let(:ignore_conditions) do
[Dependabot::Config::IgnoreCondition.new(dependency_name: "very=cool=package", versions: [">= 1"])]
end
Expand Down
12 changes: 6 additions & 6 deletions common/spec/dependabot/dependency_file_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@
described_class.new(name: "Gemfile", content: "a", directory: directory)
end

context "that starts and ends with a slash" do
context "when starting and ending with a slash" do
let(:directory) { "/path/to/files/" }

it { is_expected.to eq("/path/to/files/Gemfile") }
end

context "that doesn't start or end with a slash" do
context "when not starting or ending with a slash" do
let(:directory) { "path/to/files" }

it { is_expected.to eq("/path/to/files/Gemfile") }
Expand Down Expand Up @@ -63,13 +63,13 @@
described_class.new(name: "Gemfile", content: "a", directory: directory)
end

context "that starts and ends with a slash" do
context "when starting and ending with a slash" do
let(:directory) { "/path/to/files" }

it { is_expected.to eq("/path/to/files") }
end

context "that doesn't start or end with a slash" do
context "when not starting or ending with a slash" do
let(:directory) { "path/to/files" }

it { is_expected.to eq("/path/to/files") }
Expand Down Expand Up @@ -321,7 +321,7 @@
end

describe "#decoded_content" do
context "for base64 encoded content" do
context "when dealing with a base64 encoded content" do
let(:file) do
described_class.new(
name: "example.gem",
Expand All @@ -335,7 +335,7 @@
end
end

context "for utf-8 encoded content" do
context "when dealing with a utf-8 encoded content" do
let(:file) do
described_class.new(
name: "example.gem",
Expand Down
4 changes: 2 additions & 2 deletions common/spec/dependabot/dependency_group_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@
}
end

context "before dependencies are assigned to the group" do
context "when no dependencies are assigned to the group" do
it "returns true if the dependency matches a pattern" do
expect(dependency_group.dependencies).to eq([])
expect(dependency_group.contains?(test_dependency1)).to be_truthy
Expand All @@ -131,7 +131,7 @@
end
end

context "after dependencies are assigned to the group" do
context "when dependencies are assigned to the group" do
before do
dependency_group.dependencies << test_dependency1
end
Expand Down
2 changes: 1 addition & 1 deletion common/spec/dependabot/dependency_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@
let(:groups) { [] }
let(:package_manager) { "dummy" }

context "for a requirement that isn't top-level" do
context "when dealing with a requirement that isn't top-level" do
let(:dependency_args) do
{ name: "dep", requirements: [], package_manager: package_manager }
end
Expand Down
54 changes: 27 additions & 27 deletions common/spec/dependabot/file_fetchers/base_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def fetch_files

it { is_expected.to eq("bb218f56b14c9653891f9e74264a383fa43fefbd") }

context "that can't be found" do
context "when branch can't be found" do
before do
stub_request(:get, url + "/git/refs/heads/my_branch")
.with(headers: { "Authorization" => "token token" })
Expand All @@ -131,7 +131,7 @@ def fetch_files
end
end

context "that returns an array (because it is a substring)" do
context "when returning an array (because it is a substring)" do
before do
stub_request(:get, url + "/git/refs/heads/my_branch")
.with(headers: { "Authorization" => "token token" })
Expand Down Expand Up @@ -375,7 +375,7 @@ def fetch_files
end

context "with a directory specified" do
context "that ends in a slash" do
context "when ending in a slash" do
let(:directory) { "app/" }
let(:url) { "https://api.github.com/repos/#{repo}/contents/app/" }

Expand All @@ -386,7 +386,7 @@ def fetch_files
end
end

context "that begins with a slash" do
context "when beginning with a slash" do
let(:directory) { "/app" }
let(:url) { "https://api.github.com/repos/#{repo}/contents/app/" }

Expand All @@ -397,7 +397,7 @@ def fetch_files
end
end

context "that includes a slash" do
context "when including a slash" do
let(:directory) { "a/pp" }
let(:url) { "https://api.github.com/repos/#{repo}/contents/a/pp/" }

Expand Down Expand Up @@ -481,7 +481,7 @@ def fetch_files
its(:content) { is_expected.to include("octokit") }
end

context "that is in a submodule (shallow)" do
context "when the file is in a submodule (shallow)" do
before do
stub_request(:get, url + "some/dir/req.txt?ref=sha")
.with(headers: { "Authorization" => "token token" })
Expand Down Expand Up @@ -545,7 +545,7 @@ def fetch_files
end
end

context "that is in a submodule (deep)" do
context "when the file is in a submodule (deep)" do
before do
stub_request(:get, url + "some/dir/req.txt?ref=sha")
.with(headers: { "Authorization" => "token token" })
Expand Down Expand Up @@ -619,7 +619,7 @@ def fetch_files
end
end

context "that is in a symlinked directory" do
context "when the file is in a symlinked directory" do
before do
stub_request(:get, url + "some/dir/req.txt?ref=sha")
.with(headers: { "Authorization" => "token token" })
Expand Down Expand Up @@ -806,7 +806,7 @@ def fetch_files
child_class.new(source: source, credentials: credentials)
end

context "that ends in a slash" do
context "when ending with a slash" do
let(:directory) { "app/" }
let(:url) { project_url + "/repository/files/app%2F" }

Expand All @@ -817,7 +817,7 @@ def fetch_files
end
end

context "that begins with a slash" do
context "when beginning with a slash" do
let(:directory) { "/app" }
let(:url) { project_url + "/repository/files/app%2F" }

Expand All @@ -828,7 +828,7 @@ def fetch_files
end
end

context "that includes a slash" do
context "when including a slash" do
let(:directory) { "a/pp" }
let(:url) { project_url + "/repository/files/a%2Fpp%2F" }

Expand Down Expand Up @@ -886,7 +886,7 @@ def fetch_files
child_class.new(source: source, credentials: credentials)
end

context "that ends in a slash" do
context "when ending with a slash" do
let(:directory) { "app/" }
let(:url) { repo_url + "/src/sha/app/requirements.txt" }

Expand All @@ -896,7 +896,7 @@ def fetch_files
end
end

context "that begins with a slash" do
context "when beginning with a slash" do
let(:directory) { "/app" }
let(:url) { repo_url + "/src/sha/app/requirements.txt" }

Expand All @@ -906,7 +906,7 @@ def fetch_files
end
end

context "that includes a slash" do
context "when including a slash" do
let(:directory) { "a/pp" }
let(:url) { repo_url + "/src/sha/a/pp/requirements.txt" }

Expand Down Expand Up @@ -972,7 +972,7 @@ def fetch_files
its(:content) { is_expected.to include("required_rubygems_version") }
end

context "that can't be found" do
context "when the file can't be found" do
before do
stub_request(:get, repo_contents_url)
.to_return(status: 200,
Expand Down Expand Up @@ -1029,7 +1029,7 @@ def fetch_files
child_class.new(source: source, credentials: credentials)
end

context "that ends in a slash" do
context "when ending in a slash" do
let(:directory) { "app/" }
let(:url) do
repo_url + "/items?path=app/requirements.txt" \
Expand All @@ -1043,7 +1043,7 @@ def fetch_files
end
end

context "that begins with a slash" do
context "when beginning with a slash" do
let(:directory) { "/app" }
let(:url) do
repo_url + "/items?path=app/requirements.txt" \
Expand All @@ -1057,7 +1057,7 @@ def fetch_files
end
end

context "that includes a slash" do
context "when including a slash" do
let(:directory) { "a/pp" }
let(:url) do
repo_url + "/items?path=a/pp/requirements.txt" \
Expand Down Expand Up @@ -1147,7 +1147,7 @@ def fetch_files
its(:content) { is_expected.to include("required_rubygems_version") }
end

context "that can't be found" do
context "when the file can't be found" do
before do
stub_request(:get, repo_contents_url)
.to_return(status: 200,
Expand Down Expand Up @@ -1222,12 +1222,12 @@ def fetch_files
its(:content) { is_expected.to include("required_rubygems_version") }
end

context "with a directory specified" do
context "with directory path specified" do
let(:file_fetcher_instance) do
child_class.new(source: source, credentials: credentials)
end

context "that ends in a slash" do
context "when ending with a slash" do
before do
stubbed_cc_client
.stub_responses(
Expand All @@ -1248,7 +1248,7 @@ def fetch_files
end
end

context "that beings with a slash" do
context "when beginning with a slash" do
before do
stubbed_cc_client
.stub_responses(
Expand All @@ -1269,7 +1269,7 @@ def fetch_files
end
end

context "that includes a slash" do
context "when including a slash" do
before do
stubbed_cc_client
.stub_responses(
Expand Down Expand Up @@ -1457,7 +1457,7 @@ def optional
end
end

context "file not found" do
context "when the file is not found" do
it "raises DependencyFileNotFound" do
expect { files }
.to raise_error(Dependabot::DependencyFileNotFound) do |error|
Expand All @@ -1466,7 +1466,7 @@ def optional
end
end

context "symlink" do
context "when the directory is symlinked" do
let(:fill_repo) do
Dir.mkdir("symlinked")
file_path = File.join("symlinked", "requirements.txt")
Expand Down Expand Up @@ -1505,7 +1505,7 @@ def fetch_files
end
end

context "file not found" do
context "when the file is not found" do
it "raises DependencyFileNotFound" do
expect { files }
.to raise_error(Dependabot::DependencyFileNotFound) do |error|
Expand Down Expand Up @@ -1538,7 +1538,7 @@ def fetch_files
context "with a directory specified" do
let(:directory) { "/nested" }

context "file not found" do
context "when the file is not found" do
it "raises DependencyFileNotFound" do
expect { files }
.to raise_error(Dependabot::DependencyFileNotFound) do |error|
Expand Down
Loading

0 comments on commit 3982be4

Please sign in to comment.