Skip to content

Commit

Permalink
Implement tagged_logger by hand
Browse files Browse the repository at this point in the history
  • Loading branch information
JonRowe committed Oct 14, 2022
1 parent 90779f3 commit 50832fb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
11 changes: 6 additions & 5 deletions lib/rspec/rails/adapters.rb
Expand Up @@ -184,11 +184,12 @@ def assertion_delegator

# @private
module TaggedLoggingAdapter
require 'active_support/testing/tagged_logging'
include ActiveSupport::Testing::TaggedLogging

# Just a stub as TaggedLogging is calling `name`
def name
private
# Vendored from activesupport/lib/active_support/testing/tagged_logging.rb
# This implements the tagged_logger method where it is expected, but
# doesn't call `name` or set it up like Rails does.
def tagged_logger
@tagged_logger ||= (defined?(Rails.logger) && Rails.logger)
end
end
end
Expand Down
3 changes: 1 addition & 2 deletions spec/rspec/rails/example/rails_example_group_spec.rb
@@ -1,8 +1,7 @@
module RSpec::Rails
RSpec.describe RailsExampleGroup do
if ::Rails::VERSION::MAJOR >= 7
it 'includes ActiveSupport::Testing::TaggedLogging' do
expect(described_class.include?(::ActiveSupport::Testing::TaggedLogging)).to eq(true)
it 'supports tagged_logger' do
expect(described_class.private_instance_methods).to include(:tagged_logger)
end
end
Expand Down

0 comments on commit 50832fb

Please sign in to comment.