Sha256: 2a3dbd374ff445a24dfc3da1e7ef6422ccb4cb3c650cb266e97040b99af0454b

Contents?: true

Size: 1.11 KB

Versions: 6

Compression:

Stored size: 1.11 KB

Contents

require 'spec_helper'
require 'open3'
require 'rflow'

class RFlow
  describe Logger do
    let(:log_file_path) { File.join(@temp_directory_path, 'logfile') }
    let(:logger_config) do
      {'rflow.log_file_path' => log_file_path,
       'rflow.log_level' => 'DEBUG'}
    end

    def initialize_logger
      @logger = described_class.new(logger_config)
    end
    let(:logger) { @logger }

    before(:each) { initialize_logger }

    it 'should initialize correctly' do
      expect(File.exist?(log_file_path)).to be true

      logger.error 'TESTTESTTEST'
      expect(File.read(log_file_path)).to match(/TESTTESTTEST/)

      logger.close
    end

    it 'should reopen correctly' do
      moved_path = log_file_path + '.old'

      expect(File.exist?(log_file_path)).to be true
      expect(File.exist?(moved_path)).to be false

      File.rename log_file_path, moved_path

      logger.reopen

      logger.error 'TESTTESTTEST'
      expect(File.read(log_file_path)).to match(/TESTTESTTEST/)
      expect(File.read(moved_path)).not_to match(/TESTTESTTEST/)

      logger.close
    end

    it 'should toggle log level'
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rflow-1.3.2 spec/rflow/logger_spec.rb
rflow-1.3.1 spec/rflow/logger_spec.rb
rflow-1.3.0 spec/rflow/logger_spec.rb
rflow-1.3.0a1 spec/rflow/logger_spec.rb
rflow-1.2.0 spec/rflow/logger_spec.rb
rflow-1.1.0 spec/rflow/logger_spec.rb