Skip to content

Commit

Permalink
Enabling the RSpec BeforeAfterAll Rubocop rule
Browse files Browse the repository at this point in the history
  • Loading branch information
GarryHurleyJr committed Jun 14, 2024
1 parent 7d291b8 commit 5590c14
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 44 deletions.
33 changes: 25 additions & 8 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,6 @@ RSpec/AnyInstance:
- 'updater/spec/dependabot/dependency_change_builder_spec.rb'
- 'updater/spec/dependabot/file_fetcher_command_spec.rb'

# Offense count: 7
RSpec/BeforeAfterAll:
Exclude:
- 'nuget/spec/dependabot/nuget/update_checker/dependency_finder_spec.rb'
- 'pub/spec/dependabot/pub/file_updater_spec.rb'
- 'pub/spec/dependabot/pub/infer_sdk_versions_spec.rb'
- 'pub/spec/dependabot/pub/update_checker_spec.rb'

# Offense count: 1286
# Configuration parameters: CountAsOne.
RSpec/ExampleLength:
Expand All @@ -51,6 +43,12 @@ RSpec/FilePath:
- 'nuget/spec/dependabot/nuget/update_checker/repository_finder_spec.rb'
- 'nuget/spec/dependabot/nuget/update_checker/tfm_finder_spec.rb'

# Offense count: 56
# This cop supports safe autocorrection (--autocorrect).
RSpec/HooksBeforeExamples:
Enabled: false


# Offense count: 70
# Configuration parameters: Max, AllowedIdentifiers, AllowedPatterns.
RSpec/IndexedLet:
Expand Down Expand Up @@ -170,6 +168,25 @@ RSpec/RepeatedExampleGroupBody:
RSpec/RepeatedExampleGroupDescription:
Enabled: false

# Offense count: 36
# This cop supports safe autocorrection (--autocorrect).
RSpec/ScatteredSetup:
Exclude:
- 'bundler/spec/dependabot/bundler/file_fetcher_spec.rb'
- 'cargo/spec/dependabot/cargo/file_fetcher_spec.rb'
- 'common/spec/dependabot/clients/bitbucket_spec.rb'
- 'common/spec/dependabot/git_commit_checker_spec.rb'
- 'common/spec/dependabot/metadata_finders/base/commits_finder_spec.rb'
- 'composer/spec/dependabot/composer/update_checker_spec.rb'
- 'docker/spec/dependabot/docker/file_parser_spec.rb'
- 'elm/spec/dependabot/elm/file_fetcher_spec.rb'
- 'go_modules/spec/dependabot/go_modules/file_fetcher_spec.rb'
- 'gradle/spec/dependabot/gradle/update_checker/multi_dependency_updater_spec.rb'
- 'hex/spec/dependabot/hex/file_fetcher_spec.rb'
- 'npm_and_yarn/spec/dependabot/npm_and_yarn/metadata_finder_spec.rb'
- 'nuget/spec/dependabot/nuget/file_fetcher_spec.rb'
- 'python/spec/dependabot/python/file_fetcher_spec.rb'

# Offense count: 10
# Configuration parameters: Include, CustomTransform, IgnoreMethods, IgnoreMetadata.
# Include: **/*_spec.rb
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def create_nupkg(nuspec_name, nuspec_fixture_path)
content.sysread
end

before(:context) do
before do
disallowed_urls = %w(
https://api.nuget.org/v3/index.json
https://api.nuget.org/v3-flatcontainer/microsoft.extensions.dependencymodel/42.42.42/microsoft.extensions.dependencymodel.nuspec
Expand Down
20 changes: 7 additions & 13 deletions pub/spec/dependabot/pub/file_updater_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,29 +43,23 @@
package = File.basename(f, ".json")
@server.unmount "/api/packages/#{package}"
end
end

before do
sample_files.each do |f|
package = File.basename(f, ".json")
@server.mount_proc "/api/packages/#{package}" do |_req, res|
res.body = File.read(File.join("..", "..", "..", f))
end
end
end

after(:all) do
@server.shutdown
end

before(:all) do
before do
# Because we do the networking in dependency_services we have to run an
# actual web server.
dev_null = WEBrick::Log.new("/dev/null", 7)
@server = WEBrick::HTTPServer.new({ Port: 0, AccessLog: [], Logger: dev_null })
Thread.new do
@server.start
end
sample_files.each do |f|
package = File.basename(f, ".json")
@server.mount_proc "/api/packages/#{package}" do |_req, res|
res.body = File.read(File.join("..", "..", "..", f))
end
end
end

it_behaves_like "a dependency file updater"
Expand Down
13 changes: 5 additions & 8 deletions pub/spec/dependabot/pub/infer_sdk_versions_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,18 @@
require "webrick"

RSpec.describe "Helpers" do
before(:all) do
after do
@server.shutdown
end

before do
# Because we do the networking in infer_sdk_versions we have to run an
# actual web server.
dev_null = WEBrick::Log.new("/dev/null", 7)
@server = WEBrick::HTTPServer.new({ Port: 0, AccessLog: [], Logger: dev_null })
Thread.new do
@server.start
end
end

after(:all) do
@server.shutdown
end

before do
@server.mount_proc "/flutter_releases.json" do |_req, res|
res.body = File.read(File.join(__dir__, "..", "..", "fixtures", "flutter_releases.json"))
end
Expand Down
20 changes: 6 additions & 14 deletions pub/spec/dependabot/pub/update_checker_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,15 @@
package = File.basename(f, ".json")
@server.unmount "/api/packages/#{package}"
end
@server.shutdown
end

before do
dev_null = WEBrick::Log.new("/dev/null", 7)
@server = WEBrick::HTTPServer.new({ Port: 0, AccessLog: [], Logger: dev_null })
Thread.new do
@server.start
end
sample_files.each do |f|
package = File.basename(f, ".json")
@server.mount_proc "/api/packages/#{package}" do |_req, res|
Expand All @@ -88,20 +94,6 @@
end
end

after(:all) do
@server.shutdown
end

before(:all) do
# Because we do the networking in dependency_services we have to run an
# actual web server.
dev_null = WEBrick::Log.new("/dev/null", 7)
@server = WEBrick::HTTPServer.new({ Port: 0, AccessLog: [], Logger: dev_null })
Thread.new do
@server.start
end
end

it_behaves_like "an update checker"

context "when given an outdated dependency, not requiring unlock" do
Expand Down

0 comments on commit 5590c14

Please sign in to comment.