Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement tagged_logger by hand #2625

Merged
merged 1 commit into from Oct 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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