Sha256: c05b437f48e1a71ee599ea0b5b41c7cb86c0c2fc2a228e0bf5518df27e806278

Contents?: true

Size: 711 Bytes

Versions: 1

Compression:

Stored size: 711 Bytes

Contents

require 'spec_helper'
require 'tempfile'

describe FileSafeLogger do
  it 'has a version number' do
    expect(FileSafeLogger::VERSION).not_to be nil
  end

  context 'when removed log file after initializing logger' do
    before do
      tempfile = Tempfile.new("logger")
      tempfile.close
      @logfile = tempfile.path
      @logger = FileSafeLogger.new(@logfile)
    end

    it 'could write log file' do
      FileUtils.rm(@logfile)
      @logger.info('this is test')
      last_line = read_last_line(@logfile)
      expect(last_line).to match(/this is test/)
    end
  end

  def read_last_line(file)
    last = open(file) do |file|
      file.read.each_line {|line| line }
    end
    last
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
file_safe_logger-0.1.0 spec/file_safe_logger_spec.rb