Skip to content

Commit

Permalink
Enabling SharedExamples Rubocop rule (dependabot#9970)
Browse files Browse the repository at this point in the history
  • Loading branch information
GarryHurleyJr authored Jun 11, 2024
1 parent db38e85 commit 354a556
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 34 deletions.
10 changes: 0 additions & 10 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -212,16 +212,6 @@ RSpec/ScatteredSetup:
- 'nuget/spec/dependabot/nuget/file_fetcher_spec.rb'
- 'python/spec/dependabot/python/file_fetcher_spec.rb'

# Offense count: 24
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: string, symbol
RSpec/SharedExamples:
Exclude:
- 'pub/spec/dependabot/pub/update_checker_spec.rb'
- 'pub/spec/spec_helper.rb'
- 'updater/spec/dependabot/service_spec.rb'

# Offense count: 10
# Configuration parameters: Include, CustomTransform, IgnoreMethods, IgnoreMetadata.
# Include: **/*_spec.rb
Expand Down
6 changes: 3 additions & 3 deletions pub/spec/dependabot/pub/update_checker_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,7 @@
end

context "with a git dependency" do
include_context :uses_temp_dir
include_context "with temp dir"

let(:project) { "git_dependency" }

Expand Down Expand Up @@ -784,7 +784,7 @@
end

context "when working for a flutter project" do
include_context :uses_temp_dir
include_context "with temp dir"

let(:project) { "requires_flutter" }
let(:requirements_to_unlock) { :all }
Expand All @@ -808,7 +808,7 @@
end

context "when working for a flutter project requiring a flutter beta" do
include_context :uses_temp_dir
include_context "with temp dir"

let(:project) { "requires_latest_beta" }
let(:requirements_to_unlock) { :all }
Expand Down
2 changes: 1 addition & 1 deletion pub/spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def run_git(args, dir)
stdout
end

shared_context :uses_temp_dir do
shared_context "with temp dir" do
around do |example|
Dir.mktmpdir("rspec-") do |dir|
@temp_dir = dir
Expand Down
40 changes: 20 additions & 20 deletions updater/spec/dependabot/service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
api_client
end

shared_context :a_pr_was_created do
shared_context "with a created pr" do
let(:source) do
instance_double(Dependabot::Source, provider: "github", repo: "dependabot/dependabot-core", directory: "/")
end
Expand Down Expand Up @@ -98,7 +98,7 @@
end
end

shared_context :a_pr_was_updated do
shared_context "with an updated pr" do
let(:source) do
instance_double(Dependabot::Source, provider: "github", repo: "dependabot/dependabot-core", directory: "/")
end
Expand Down Expand Up @@ -147,7 +147,7 @@
end
end

shared_context :a_pr_was_closed do
shared_context "with an closd pr" do
let(:dependency_name) { "dependabot-fortran" }
let(:reason) { :dependency_removed }

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

shared_context :an_error_was_reported do
shared_context "with a reported error" do
before do
service.record_update_job_error(
error_type: :epoch_error,
Expand All @@ -167,7 +167,7 @@
end
end

shared_context :a_dependency_error_was_reported do
shared_context "with a reported dependency error" do
let(:dependency) do
Dependabot::Dependency.new(
name: "dependabot-cobol",
Expand Down Expand Up @@ -218,7 +218,7 @@
end

describe "#create_pull_request" do
include_context :a_pr_was_created
include_context "with a created pr"

before do
Dependabot::Experiments.register("dependency_change_validation", true)
Expand Down Expand Up @@ -263,7 +263,7 @@
end

describe "#update_pull_request" do
include_context :a_pr_was_updated
include_context "with an updated pr"

it "delegates to @client" do
expect(mock_client).to have_received(:update_pull_request).with(dependency_change, base_sha)
Expand All @@ -275,7 +275,7 @@
end

describe "#close_pull_request" do
include_context :a_pr_was_closed
include_context "with an closd pr"

it "delegates to @client" do
expect(mock_client).to have_received(:close_pull_request).with(dependency_name, reason)
Expand All @@ -287,7 +287,7 @@
end

describe "#record_update_job_error" do
include_context :an_error_was_reported
include_context "with a reported error"

it "delegates to @client" do
expect(mock_client).to have_received(:record_update_job_error).with(
Expand Down Expand Up @@ -515,7 +515,7 @@
end

context "when a pr was created" do
include_context :a_pr_was_created
include_context "with a created pr"

it "includes the summary of the created PR" do
service.create_pull_request(dependency_change, base_sha)
Expand All @@ -527,7 +527,7 @@
end

context "when a pr was updated" do
include_context :a_pr_was_updated
include_context "with an updated pr"

it "includes the summary of the updated PR" do
expect(service.summary)
Expand All @@ -536,7 +536,7 @@
end

context "when a pr was closed" do
include_context :a_pr_was_closed
include_context "with an closd pr"

it "includes the summary of the closed PR" do
expect(service.summary)
Expand All @@ -545,7 +545,7 @@
end

context "when there was an error" do
include_context :an_error_was_reported
include_context "with a reported error"

it "includes an error count" do
expect(service.summary)
Expand All @@ -559,7 +559,7 @@
end

context "when there was an dependency error" do
include_context :a_dependency_error_was_reported
include_context "with a reported dependency error"

it "includes an error count" do
expect(service.summary)
Expand All @@ -575,8 +575,8 @@
end

context "when there was a mix of pr activity" do
include_context :a_pr_was_updated
include_context :a_pr_was_closed
include_context "with an updated pr"
include_context "with an closd pr"

it "includes the summary of the updated PR" do
expect(service.summary)
Expand All @@ -590,10 +590,10 @@
end

context "when there was a mix of pr and error activity" do
include_context :a_pr_was_created
include_context :a_pr_was_closed
include_context :an_error_was_reported
include_context :a_dependency_error_was_reported
include_context "with a created pr"
include_context "with an closd pr"
include_context "with a reported error"
include_context "with a reported dependency error"

before do
service.create_pull_request(dependency_change, base_sha)
Expand Down

0 comments on commit 354a556

Please sign in to comment.