Skip to content

Commit

Permalink
test-improvement-6017: Rspec/ContextWording task grouped by ecosystem. (
Browse files Browse the repository at this point in the history
#9758)

* test-improvement-6017: Rspec/ContextWording task grouped by ecosystem.

* test-improvement-6017: removing additional empty line.

* context-wording-bundler: Context Wording Updated for Bundler.

* context-wording-bundler: ensuring all the include_context is in sync with shared_context.

---------

Co-authored-by: “Thavachelvam <“thavaahariharangit@git.com”>
  • Loading branch information
thavaahariharangit and “Thavachelvam committed May 17, 2024
1 parent 9e61a91 commit 85dcd0b
Show file tree
Hide file tree
Showing 37 changed files with 295 additions and 276 deletions.
21 changes: 20 additions & 1 deletion .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,26 @@ RSpec/BeforeAfterAll:
# Configuration parameters: Prefixes, AllowedPatterns.
# Prefixes: when, with, without
RSpec/ContextWording:
Enabled: false
Exclude:
- 'cargo/**/*'
- 'common/**/*'
- 'composer/**/*'
- 'devcontainers/**/*'
- 'docker/**/*'
- 'elm/**/*'
- 'git_submodules/**/*'
- 'github_actions/**/*'
- 'go_modules/**/*'
- 'gradle/**/*'
- 'hex/**/*'
- 'maven/**/*'
- 'npm_and_yarn/**/*'
- 'nuget/**/*'
- 'pub/**/*'
- 'python/**/*'
- 'sorbet/**/*'
- 'terraform/**/*'
- 'updater/**/*'

# Offense count: 31
# This cop supports unsafe autocorrection (--autocorrect-all).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
require "shared_contexts"

RSpec.describe Functions::ConflictingDependencyResolver do
include_context "in a temporary bundler directory"
include_context "when in a temporary bundler directory"

let(:conflicting_dependency_resolver) do
described_class.new(
Expand Down Expand Up @@ -36,7 +36,7 @@
)
end

context "for nested transitive dependencies" do
context "when dealing with nested transitive dependencies" do
let(:project_name) { "transitive_blocking" }
let(:dependency_name) { "activesupport" }
let(:target_version) { "6.0.0" }
Expand Down
14 changes: 7 additions & 7 deletions bundler/helpers/v1/spec/functions/dependency_source_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
require "shared_contexts"

RSpec.describe Functions::DependencySource do
include_context "in a temporary bundler directory"
include_context "when in a temporary bundler directory"

let(:dependency_source) do
described_class.new(
Expand Down Expand Up @@ -47,7 +47,7 @@
])
end

context "specified as the default source" do
context "when specified as the default source" do
let(:project_name) { "specified_default_source_no_lockfile" }

it "returns all versions from the private source" do
Expand All @@ -59,7 +59,7 @@
end
end

context "that we don't have authentication details for" do
context "when we don't have authentication details for" do
before do
stub_request(:get, registry_url + "versions")
.with(basic_auth: ["SECRET_CODES", ""])
Expand All @@ -83,7 +83,7 @@
end
end

context "that we have bad authentication details for" do
context "when we have bad authentication details" do
before do
stub_request(:get, registry_url + "versions")
.with(basic_auth: ["SECRET_CODES", ""])
Expand All @@ -107,7 +107,7 @@
end
end

context "that bad-requested, but was a private repo" do
context "when bad-requested, but is a private repo" do
before do
stub_request(:get, registry_url + "versions")
.with(basic_auth: ["SECRET_CODES", ""])
Expand All @@ -130,7 +130,7 @@
end
end

context "that doesn't have details of the gem" do
context "when it doesn't have details of the gem" do
before do
stub_request(:get, gemfury_business_url)
.with(basic_auth: ["SECRET_CODES", ""])
Expand All @@ -152,7 +152,7 @@
it { is_expected.to be_empty }
end

context "that only implements the old Bundler index format..." do
context "when it only implements the old Bundler index format" do
let(:project_name) { "sidekiq_pro" }
let(:dependency_name) { "sidekiq-pro" }
let(:registry_url) { "https://gems.contribsys.com/" }
Expand Down
2 changes: 1 addition & 1 deletion bundler/helpers/v1/spec/functions/file_parser_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
require "shared_contexts"

RSpec.describe Functions::FileParser do
include_context "in a temporary bundler directory"
include_context "when in a temporary bundler directory"

let(:dependency_source) do
described_class.new(
Expand Down
4 changes: 2 additions & 2 deletions bundler/helpers/v1/spec/functions/force_updater_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
require "shared_contexts"

RSpec.describe Functions::ForceUpdater do
include_context "in a temporary bundler directory"
include_context "stub rubygems compact index"
include_context "when in a temporary bundler directory"
include_context "when stubbing rubygems compact index"

let(:force_updater) do
described_class.new(
Expand Down
6 changes: 3 additions & 3 deletions bundler/helpers/v1/spec/functions/version_resolver_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
require "shared_contexts"

RSpec.describe Functions::VersionResolver do
include_context "in a temporary bundler directory"
include_context "stub rubygems compact index"
include_context "when in a temporary bundler directory"
include_context "when stubbing rubygems compact index"

let(:version_resolver) do
described_class.new(
Expand Down Expand Up @@ -43,7 +43,7 @@
its([:fetcher]) { is_expected.to eq("Bundler::Fetcher::CompactIndex") }

context "with a private gemserver source" do
include_context "stub rubygems compact index"
include_context "when stubbing rubygems compact index"

let(:project_name) { "specified_source" }
let(:requirement_string) { ">= 0" }
Expand Down
4 changes: 2 additions & 2 deletions bundler/helpers/v1/spec/shared_contexts.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

TMP_DIR_PATH = File.expand_path("../tmp", __dir__)

RSpec.shared_context "in a temporary bundler directory" do
RSpec.shared_context "when in a temporary bundler directory" do
let(:project_name) { "gemfile" }

let(:tmp_path) do
Expand Down Expand Up @@ -34,7 +34,7 @@ def in_tmp_folder(&block)
end
end

RSpec.shared_context "stub rubygems compact index" do
RSpec.shared_context "when stubbing rubygems compact index" do
include_context "without caching rubygems"

before do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
require "shared_contexts"

RSpec.describe Functions::ConflictingDependencyResolver do
include_context "in a temporary bundler directory"
include_context "when in a temporary bundler directory"

let(:conflicting_dependency_resolver) do
described_class.new(
Expand Down Expand Up @@ -36,7 +36,7 @@
)
end

context "for nested transitive dependencies" do
context "when dealing with nested transitive dependencies" do
let(:project_name) { "transitive_blocking" }
let(:dependency_name) { "activesupport" }
let(:target_version) { "6.0.0" }
Expand Down
14 changes: 7 additions & 7 deletions bundler/helpers/v2/spec/functions/dependency_source_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
require "shared_contexts"

RSpec.describe Functions::DependencySource do
include_context "in a temporary bundler directory"
include_context "when in a temporary bundler directory"

let(:dependency_source) do
described_class.new(
Expand Down Expand Up @@ -47,7 +47,7 @@
])
end

context "specified as the default source" do
context "when specified as the default source" do
let(:project_name) { "specified_default_source_no_lockfile" }

it "returns all versions from the private source" do
Expand All @@ -59,7 +59,7 @@
end
end

context "that we don't have authentication details for" do
context "when we don't have authentication details" do
before do
stub_request(:get, registry_url + "versions")
.with(basic_auth: ["SECRET_CODES", ""])
Expand All @@ -82,7 +82,7 @@
end
end

context "that we have bad authentication details for" do
context "when we have bad authentication details" do
before do
stub_request(:get, registry_url + "versions")
.with(basic_auth: ["SECRET_CODES", ""])
Expand All @@ -105,7 +105,7 @@
end
end

context "that bad-requested, but was a private repo" do
context "when there is a bad request but it's a private repo" do
before do
stub_request(:get, registry_url + "versions")
.with(basic_auth: ["SECRET_CODES", ""])
Expand All @@ -131,7 +131,7 @@
end
end

context "that doesn't have details of the gem" do
context "when the gem details are not available" do
before do
stub_request(:get, gemfury_business_url)
.with(basic_auth: ["SECRET_CODES", ""])
Expand All @@ -153,7 +153,7 @@
it { is_expected.to be_empty }
end

context "that only implements the old Bundler index format..." do
context "when only the old Bundler index format is implemented" do
let(:project_name) { "sidekiq_pro" }
let(:dependency_name) { "sidekiq-pro" }
let(:registry_url) { "https://gems.contribsys.com/" }
Expand Down
2 changes: 1 addition & 1 deletion bundler/helpers/v2/spec/functions/file_parser_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
require "shared_contexts"

RSpec.describe Functions::FileParser do
include_context "in a temporary bundler directory"
include_context "when in a temporary bundler directory"

let(:dependency_source) do
described_class.new(
Expand Down
4 changes: 2 additions & 2 deletions bundler/helpers/v2/spec/functions/force_updater_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
require "shared_contexts"

RSpec.describe Functions::ForceUpdater do
include_context "in a temporary bundler directory"
include_context "stub rubygems compact index"
include_context "when in a temporary bundler directory"
include_context "when stubbing rubygems compact index"

let(:force_updater) do
described_class.new(
Expand Down
6 changes: 3 additions & 3 deletions bundler/helpers/v2/spec/functions/version_resolver_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
require "shared_contexts"

RSpec.describe Functions::VersionResolver do
include_context "in a temporary bundler directory"
include_context "stub rubygems compact index"
include_context "when in a temporary bundler directory"
include_context "when stubbing rubygems compact index"

let(:version_resolver) do
described_class.new(
Expand Down Expand Up @@ -52,7 +52,7 @@
its([:fetcher]) { is_expected.to eq("Bundler::Fetcher::CompactIndex") }

context "with a private gemserver source" do
include_context "stub rubygems compact index"
include_context "when stubbing rubygems compact index"

let(:project_name) { "specified_source" }
let(:requirement_string) { ">= 0" }
Expand Down
2 changes: 1 addition & 1 deletion bundler/helpers/v2/spec/functions_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
require "shared_contexts"

RSpec.describe Functions do
include_context "in a temporary bundler directory"
include_context "when in a temporary bundler directory"

describe "#jfrog_source" do
let(:project_name) { "jfrog_source" }
Expand Down
4 changes: 2 additions & 2 deletions bundler/helpers/v2/spec/ruby_version_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
require "shared_contexts"

RSpec.describe BundlerDefinitionRubyVersionPatch do
include_context "in a temporary bundler directory"
include_context "stub rubygems compact index"
include_context "when in a temporary bundler directory"
include_context "when stubbing rubygems compact index"

let(:project_name) { "ruby_version_implied" }
before do
Expand Down
4 changes: 2 additions & 2 deletions bundler/helpers/v2/spec/shared_contexts.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

TMP_DIR_PATH = File.expand_path("../tmp", __dir__)

RSpec.shared_context "in a temporary bundler directory" do
RSpec.shared_context "when in a temporary bundler directory" do
let(:project_name) { "gemfile" }

let(:tmp_path) do
Expand All @@ -27,7 +27,7 @@ def in_tmp_folder(&block)
end
end

RSpec.shared_context "stub rubygems compact index" do
RSpec.shared_context "when stubbing rubygems compact index" do
before do
# Stub the Rubygems index
stub_request(:get, "https://index.rubygems.org/versions")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
let(:gemfile) { bundler_project_dependency_file("eval_gemfile_gemfile", filename: "Gemfile") }
it { is_expected.to eq(["backend/Gemfile"]) }

context "whose path must be eval-ed" do
context "when path must be eval-ed" do
let(:gemfile) { bundler_project_dependency_file("eval_gemfile_absolute", filename: "Gemfile") }

it "raises a helpful error" do
Expand All @@ -34,7 +34,7 @@
end
end

context "that includes a variable" do
context "when that includes a variable" do
let(:gemfile) { bundler_project_dependency_file("eval_gemfile_variable", filename: "Gemfile") }

it "raises a helpful error" do
Expand All @@ -45,7 +45,7 @@
end
end

context "within a group block" do
context "when within a group block" do
let(:gemfile_body) do
"group :development do\neval_gemfile('some_gemfile')\nend"
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
let(:gemfile) { bundler_project_dependency_file("imports_gemspec", filename: "Gemfile") }
it { is_expected.to eq([Pathname.new(".")]) }

context "that has a path specified" do
context "when that has a path specified" do
let(:gemfile) { bundler_project_dependency_file("imports_gemspec_from_path", filename: "Gemfile") }

it { is_expected.to eq([Pathname.new("subdir")]) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
let(:gemfile) { bundler_project_dependency_file("path_source", filename: "Gemfile") }
it { is_expected.to eq([Pathname.new("plugins/example")]) }

context "whose path must be eval-ed" do
context "when the path must be eval-ed" do
let(:gemfile) { bundler_project_dependency_file("path_source_eval", filename: "Gemfile") }

it "raises a helpful error" do
Expand All @@ -54,7 +54,7 @@
it { is_expected.to eq([Pathname.new("nested/plugins/example")]) }
end

context "that is behind a conditional that is false" do
context "when that is behind a conditional that is false" do
let(:gemfile) { bundler_project_dependency_file("path_source_if", filename: "Gemfile") }
it { is_expected.to eq([Pathname.new("plugins/example")]) }
end
Expand Down

0 comments on commit 85dcd0b

Please sign in to comment.