Sha256: 91ab56e5d94085eb7a397610adc7ed28c906db7c99314bf605bbddccbd67e86d

Contents?: true

Size: 1.46 KB

Versions: 1

Compression:

Stored size: 1.46 KB

Contents

require 'spec_helper'

describe LoGspot do
  let(:filename) { File.expand_path('../../tmp/spec.log', __FILE__) }

  before do
    FileUtils.rm(filename)
  end

  let(:tag_format) { '' }
  let(:logger) { LoGspot.new(filename, tag_format: tag_format) }
  let(:read) { -> { File.read(filename) } }

  describe '#write' do
    it 'should output properly' do
      logger.info('test')
      expect(read.()).to eq "test\n"
    end
  end

  describe '#value' do
    it 'should output properly' do
      logger.value(:info, test: 'test')
      expect(read.()).to eq "test: test\n"
    end
  end

  describe '#tagged' do
    it 'should output properly' do
      logger.tagged('tag') do
        logger.info('test')
      end
      expect(read.()).to eq "tagtest\n"
    end
  end

  describe '#untagged' do
    it 'should output properly' do
      logger.tagged('tag') do
        logger.tagged('tag2') do
          logger.untagged do
            logger.info('test')
          end
        end
      end
      expect(read.()).to eq "tagtest\n"
    end
  end

  describe '#top' do
    let(:tag_format) { 'a' }

    it 'should output properly' do
      logger.tagged('tag') do
        logger.top do
          logger.info('test')
        end
      end
      expect(read.()).to eq "atest\n"
    end
  end

  describe '#raw' do
    let(:tag_format) { 'a' }

    it 'should output properly' do
      logger.tagged('tag') do
        logger.raw('test')
      end
      expect(read.()).to eq "test"
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
logspot-0.6.0 spec/logspot_spec.rb