File: logger.rb

package info (click to toggle)
ruby-hashie 5.0.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 884 kB
  • sloc: ruby: 7,049; sh: 8; makefile: 6
file content (24 lines) | stat: -rw-r--r-- 625 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# A shared context that allows you to check the output of Hashie's logger.
#
# @example
#   include_context 'with a logger'
#
#   it 'logs info message' do
#     Hashie.logger.info 'What is happening in here?!'
#
#     expect(logger_output).to match('What is happening in here?!')
#   end
RSpec.shared_context 'with a logger' do
  # @private
  let(:log) { StringIO.new }

  # The output string from the logger
  let(:logger_output) { log.rewind && log.string }

  around(:each) do |example|
    original_logger = Hashie.logger
    Hashie.logger = Logger.new(log)
    example.run
    Hashie.logger = original_logger
  end
end