Sha256: f42ba94d065a716fad6e2d785936a807c93e7674782b5c1b2717c701d7049651

Contents?: true

Size: 595 Bytes

Versions: 2

Compression:

Stored size: 595 Bytes

Contents

# A shared context that allows you to check the output of Hashie's logger.
#
# @example
#   shared_context 'with a logger' 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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
hashie-3.5.1 spec/support/logger.rb
hashie-3.5.0 spec/support/logger.rb