Skip to content

Commit

Permalink
Remove test dependency on logger
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
deivid-rodriguez authored and hsbt committed Jan 14, 2025
1 parent 78cec33 commit a3882dc
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 11 deletions.
3 changes: 1 addition & 2 deletions spec/bundler/install/gems/dependency_api_fallback_spec.rb
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -11,6 +9,7 @@
@server_uri = "http://127.0.0.1:#{port}"

require_relative "../../support/artifice/endpoint_timeout"
require_relative "../../support/silent_logger"

require "rackup/server"

Expand Down
3 changes: 1 addition & 2 deletions spec/bundler/realworld/gemfile_source_header_spec.rb
Original file line number Diff line number Diff line change
@@ -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}" }
Expand Down Expand Up @@ -38,6 +36,7 @@ def setup_server
@server_uri = "http://127.0.0.1:#{@port}"

require_relative "../support/artifice/endpoint_mirror_source"
require_relative "../support/silent_logger"

require "rackup/server"

Expand Down
3 changes: 1 addition & 2 deletions spec/bundler/realworld/mirror_probe_spec.rb
Original file line number Diff line number Diff line change
@@ -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 }
Expand Down Expand Up @@ -111,6 +109,7 @@ def setup_server
@server_uri = "http://#{host}:#{@server_port}"

require_relative "../support/artifice/endpoint"
require_relative "../support/silent_logger"

require "rackup/server"

Expand Down
8 changes: 4 additions & 4 deletions spec/bundler/support/silent_logger.rb
Original file line number Diff line number Diff line change
@@ -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
1 change: 0 additions & 1 deletion tool/bundler/dev_gems.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
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
Expand Down

0 comments on commit a3882dc

Please sign in to comment.