Remove test dependency on logger

I think logger is only used to figure out which methods need to be made
noops in order to silence webrick during tests.

However, it seems possible to do the same using webrick's builtin logger
and the current method does not seem even correct since it's not
guaranteed that the logger gem and webrick's logger will use the same
methods.
This commit is contained in:
David Rodríguez 2025-01-10 12:29:08 +01:00 committed by Hiroshi SHIBATA
parent 78cec33958
commit a3882dc565
Notes: git 2025-01-14 03:24:57 +00:00
5 changed files with 7 additions and 11 deletions

View File

@ -1,7 +1,5 @@
# frozen_string_literal: true
require_relative "../../support/silent_logger"
RSpec.describe "gemcutter's dependency API" do
context "when Gemcutter API takes too long to respond" do
before do
@ -11,6 +9,7 @@ RSpec.describe "gemcutter's dependency API" do
@server_uri = "http://127.0.0.1:#{port}"
require_relative "../../support/artifice/endpoint_timeout"
require_relative "../../support/silent_logger"
require "rackup/server"

View File

@ -1,7 +1,5 @@
# frozen_string_literal: true
require_relative "../support/silent_logger"
RSpec.describe "fetching dependencies with a mirrored source", realworld: true do
let(:mirror) { "https://server.example.org" }
let(:original) { "http://127.0.0.1:#{@port}" }
@ -38,6 +36,7 @@ RSpec.describe "fetching dependencies with a mirrored source", realworld: true d
@server_uri = "http://127.0.0.1:#{@port}"
require_relative "../support/artifice/endpoint_mirror_source"
require_relative "../support/silent_logger"
require "rackup/server"

View File

@ -1,7 +1,5 @@
# frozen_string_literal: true
require_relative "../support/silent_logger"
RSpec.describe "fetching dependencies with a not available mirror", realworld: true do
let(:mirror) { @mirror_uri }
let(:original) { @server_uri }
@ -111,6 +109,7 @@ RSpec.describe "fetching dependencies with a not available mirror", realworld: t
@server_uri = "http://#{host}:#{@server_port}"
require_relative "../support/artifice/endpoint"
require_relative "../support/silent_logger"
require "rackup/server"

View File

@ -1,10 +1,10 @@
# frozen_string_literal: true
require "logger"
require "webrick"
module Spec
class SilentLogger
(::Logger.instance_methods - Object.instance_methods).each do |logger_instance_method|
define_method(logger_instance_method) {|*args, &blk| }
class SilentLogger < WEBrick::BasicLog
def initialize(log_file = nil, level = nil)
super(log_file, level || FATAL)
end
end
end

View File

@ -13,7 +13,6 @@ gem "rspec-core", "~> 3.12"
gem "rspec-expectations", "~> 3.12"
gem "rspec-mocks", "~> 3.12"
gem "uri", "~> 0.13.0"
gem "logger", "~> 1.6.5"
group :doc do
gem "ronn-ng", "~> 0.10.1", platform: :ruby