You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Tag from tagged logger is lost in between and content is not being honored when calling original if any logging (warn/info/debug/...) method is stubbed
Expected behaviour
The tagged logger content should be preserved when using and_call_original for stubbing any logging (warn/info/debug/...) methods
Can you provide an example app?
# frozen_string_literal: truerequire'bundler/inline'gemfile(true)dosource'https://rubygems.org'git_source(:github){ |repo| "https://github.com/#{repo}.git"}gem'rails','~> 7.0.2.3'gem'rspec-rails','~> 5.1.1'endrequire'active_support'require'active_support/core_ext/object/blank'require'action_controller/railtie'require'action_view/railtie'require'minitest/autorun'classBugTest < Minitest::Testdeftest_custom_loggerio=StringIO.newlogger=ActiveSupport::Logger.new(io)tagged_logger=ActiveSupport::TaggedLogging.new(logger)tagged_logger.tagged('FOO'){ |logger| logger.info'bar 2333'}assert_equal"[FOO] bar 2333\n",io.stringendendrequire'rspec/autorun'require'rspec/rails'RSpec.configuredo |config|
config.filter_run_excludingskip: trueconfig.run_all_when_everything_filtered=trueconfig.filter_runfocus: trueendRSpec.describe'TaggedLogging'dolet(:io){StringIO.new}let(:logger){Logger.new(io)}beforedo# commenting this out would allow the message pass through correctlyallow(logger).toreceive(:info).and_call_originaltagged_logger=ActiveSupport::TaggedLogging.new(logger)tagged_logger.tagged('FOO'){ |logger| logger.info'bar 2333'}endit{expect(logger).tohave_received(:info).once}it'includes tags'do# Expectation: [FOO] bar 2333# Result: I, [2022-04-16T23:23:44.481396 #12280] INFO -- : bar 2333expect(io.string).toeq("[FOO] bar 2333\n")endend
The text was updated successfully, but these errors were encountered:
Can yoiu check out #2587 and see if it fixes this? Theres no built in support for the tagged logger currently and I suspect this is an "ordering" issue with the method calls
Can you check out #2587 and see if it fixes this? Theres no built in support for the tagged logger currently and I suspect this is an "ordering" issue with the method calls
I have tried one of the branch directly, unless I have to call include RSpec::Rails::TaggedLoggingAdapter in the setup, i believe the issue hasn't been fixed.
What Ruby, Rails and RSpec versions are you using?
Ruby version: 2.7+
Rails version: 7.0.2.3
RSpec version: 5.1.1
Observed behaviour
Tag from tagged logger is lost in between and content is not being honored when calling original if any logging (warn/info/debug/...) method is stubbed
Expected behaviour
The tagged logger content should be preserved when using
and_call_original
for stubbing any logging (warn/info/debug/...) methodsCan you provide an example app?
The text was updated successfully, but these errors were encountered: