Sha256: 558de6c398e4f7e720fdc2bc51202e1671d6f00fe5540515bb68621f2c255a53

Contents?: true

Size: 1.09 KB

Versions: 1

Compression:

Stored size: 1.09 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
      File.exist?(log_file_path).should be true

      logger.error "TESTTESTTEST"
      File.read(log_file_path).should match(/TESTTESTTEST/)

      logger.close
    end

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

      File.exist?(log_file_path).should be true
      File.exist?(moved_path).should be false

      File.rename log_file_path, moved_path

      logger.reopen

      logger.error "TESTTESTTEST"
      File.read(log_file_path).should match(/TESTTESTTEST/)
      File.read(moved_path).should_not match(/TESTTESTTEST/)

      logger.close
    end

    it "should toggle log level"
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rflow-1.0.0a2 spec/rflow/logger_spec.rb