Sha256: 1b5efc30c8600a1d0a9277164df73b7341c9db723c8ac1614ac78d9c739c68ae

Contents?: true

Size: 949 Bytes

Versions: 15

Compression:

Stored size: 949 Bytes

Contents

require 'spec_helper'

describe DaemonsLogger do
  context 'new' do
    it 'creates logger with path string' do
      Tempfile.open('daemons_logger') do |io|
        logger = DaemonsLogger.new(io.path)
        expect(logger.class).to eq(DaemonsLogger)
        logger.close
        logger.close
      end
    end

    it 'creates logger with IO object' do
      io = double('dummy io', write: nil, close: nil)
      expect(DaemonsLogger.new(io).class).to eq(DaemonsLogger)
    end
  end

  context 'reopen' do
    it 'reopens IOs' do
      Tempfile.open('daemons_logger') do |f|
        logger = DaemonsLogger.new(f.path)
        expect(STDOUT).to receive(:reopen).twice
        logger.hook_stdout!
        expect(STDERR).to receive(:reopen).twice
        logger.hook_stderr!
        logger.reopen
        io = logger.instance_variable_get(:@log)
        allow(logger).to receive(:reopen!) { raise }
        logger.reopen
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
perfectqueue-0.8.54 spec/daemons_logger_spec.rb
perfectqueue-0.10.1 spec/daemons_logger_spec.rb
perfectqueue-0.8.53 spec/daemons_logger_spec.rb
perfectqueue-0.8.52 spec/daemons_logger_spec.rb
perfectqueue-0.10.0 spec/daemons_logger_spec.rb
perfectqueue-0.8.51 spec/daemons_logger_spec.rb
perfectqueue-0.8.50 spec/daemons_logger_spec.rb
perfectqueue-0.9.2 spec/daemons_logger_spec.rb
perfectqueue-0.9.1 spec/daemons_logger_spec.rb
perfectqueue-0.9.0 spec/daemons_logger_spec.rb
perfectqueue-0.8.49 spec/daemons_logger_spec.rb
perfectqueue-0.8.48 spec/daemons_logger_spec.rb
perfectqueue-0.8.47 spec/daemons_logger_spec.rb
perfectqueue-0.8.46 spec/daemons_logger_spec.rb
perfectqueue-0.8.45 spec/daemons_logger_spec.rb