Sha256: e1fbdd210c1a205a6118ae596f1e8ddeb19865d299c2b9e326e1c431186b2440

Contents?: true

Size: 992 Bytes

Versions: 2

Compression:

Stored size: 992 Bytes

Contents

require 'spec_helper'

describe Logasm::Utils do
  describe '.build_event' do
    subject(:event) { described_class.build_event(metadata, level, service_name) }

    let(:service_name) { 'test_service' }
    let(:level)        { 'INFO' }
    let(:metadata)     { {x: 'y'} }

    context 'when service name is in correct format' do
      it 'includes it in the event as application' do
        expect(event[:application]).to eq('test_service')
      end
    end

    context 'when service name is in camelcase' do
      let(:service_name) { 'InformationService' }

      it 'includes it in the event as lower snake case' do
        expect(event[:application]).to eq('information_service')
      end
    end

    it 'includes level as a lower case string' do
      expect(event[:level]).to eq('info')
    end

    it 'includes timestamp' do
      expect(event[:@timestamp]).to match(/\d{4}.*/)
    end

    it 'includes the host' do
      expect(event[:host]).to be_a(String)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
logasm-0.2.3 spec/utils_spec.rb
logasm-0.2.2 spec/utils_spec.rb