File: customized_logger_spec.rb

package info (click to toggle)
ruby-uniform-notifier 1.16.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 240 kB
  • sloc: ruby: 915; makefile: 4
file content (24 lines) | stat: -rw-r--r-- 739 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe UniformNotifier::CustomizedLogger do
  it 'should not notify to customized logger' do
    expect(UniformNotifier::CustomizedLogger.out_of_channel_notify(title: 'notify rails logger')).to be_nil
  end

  it 'should notify to customized logger' do
    logger = File.open('test.log', 'a+')
    logger.sync = true

    now = Time.now
    allow(Time).to receive(:now).and_return(now)
    UniformNotifier.customized_logger = logger
    UniformNotifier::CustomizedLogger.out_of_channel_notify(title: 'notify rails logger')

    logger.seek(0)
    expect(logger.read).to eq "#{now.strftime('%Y-%m-%d %H:%M:%S')}[WARN] notify rails logger"

    File.delete('test.log')
  end
end