Sha256: 0b2ceb16f1d31ded2fef8bd8f1587ee7195b8cf48283193452da87f3d1e60ce0
Contents?: true
Size: 1.47 KB
Versions: 1
Compression:
Stored size: 1.47 KB
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 context 'when @timestamp provided' do let(:metadata) { {message: 'test', :@timestamp => 'a timestamp'} } it 'overwrites @timestamp' do expect(subject[:message]).to eq('test') expect(subject[:@timestamp]).to eq('a timestamp') end end context 'when host provided' do let(:metadata) { {message: 'test', host: 'xyz'} } it 'overwrites host' do expect(subject[:message]).to eq('test') expect(subject[:host]).to eq('xyz') end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
logasm-0.2.4 | spec/utils_spec.rb |