diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-23 19:44:23 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-23 19:44:23 +0000 |
commit | 6b96d119aec0ba674cca2c380cf60f1500306612 (patch) | |
tree | f7742d802f557d04e2144b06a2b47719fbd58b82 /spec/support | |
parent | 8b7c4494871c7d69ac7bc59839bdce6ff2937f95 (diff) | |
download | gitlab-ce-6b96d119aec0ba674cca2c380cf60f1500306612.tar.gz |
Add latest changes from gitlab-org/gitlab@13-1-stable-ee
Diffstat (limited to 'spec/support')
-rw-r--r-- | spec/support/shared_contexts/controllers/logging_shared_context.rb | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/spec/support/shared_contexts/controllers/logging_shared_context.rb b/spec/support/shared_contexts/controllers/logging_shared_context.rb new file mode 100644 index 00000000000..986a96f3a8d --- /dev/null +++ b/spec/support/shared_contexts/controllers/logging_shared_context.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +# This context replaces the logger and exposes the `log_data` variable for +# inspection +RSpec.shared_context 'parsed logs' do + let(:logger) do + Logger.new(log_output).tap { |logger| logger.formatter = ->(_, _, _, msg) { msg } } + end + + let(:log_output) { StringIO.new } + let(:log_data) { Gitlab::Json.parse(log_output.string) } + + around do |example| + initial_logger = Lograge.logger + Lograge.logger = logger + + example.run + + Lograge.logger = initial_logger + end +end |