Skip to content

Commit 50832fb

Browse files
committed
Implement tagged_logger by hand
1 parent 90779f3 commit 50832fb

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

lib/rspec/rails/adapters.rb

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -184,11 +184,12 @@ def assertion_delegator
184184

185185
# @private
186186
module TaggedLoggingAdapter
187-
require 'active_support/testing/tagged_logging'
188-
include ActiveSupport::Testing::TaggedLogging
189-
190-
# Just a stub as TaggedLogging is calling `name`
191-
def name
187+
private
188+
# Vendored from activesupport/lib/active_support/testing/tagged_logging.rb
189+
# This implements the tagged_logger method where it is expected, but
190+
# doesn't call `name` or set it up like Rails does.
191+
def tagged_logger
192+
@tagged_logger ||= (defined?(Rails.logger) && Rails.logger)
192193
end
193194
end
194195
end

spec/rspec/rails/example/rails_example_group_spec.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
module RSpec::Rails
22
RSpec.describe RailsExampleGroup do
33
if ::Rails::VERSION::MAJOR >= 7
4-
it 'includes ActiveSupport::Testing::TaggedLogging' do
5-
expect(described_class.include?(::ActiveSupport::Testing::TaggedLogging)).to eq(true)
4+
it 'supports tagged_logger' do
65
expect(described_class.private_instance_methods).to include(:tagged_logger)
76
end
87
end

0 commit comments

Comments
 (0)