spec/loga/sidekiq_spec.rb in loga-2.5.2 vs spec/loga/sidekiq_spec.rb in loga-2.5.3

- old
+ new

@@ -1,10 +1,10 @@ require 'spec_helper' RSpec.describe Loga::Sidekiq do describe '.configure_logging' do - context 'when sidekiq version is 5.1' do + context 'when sidekiq is defined' do it 'gets invoked on Loga.configure' do allow(described_class).to receive(:configure_logging) Loga.reset @@ -16,20 +16,27 @@ ) expect(described_class).to have_received(:configure_logging) end - it 'assigns our custom sidekiq job logger' do + it 'assigns our custom sidekiq job logger depending on the sidekiq version' do Loga.reset Loga.configure( service_name: 'hello_world_app', service_version: '1.0', device: StringIO.new, format: :gelf, ) - expect(::Sidekiq.options[:job_logger]).to eq(Loga::Sidekiq::JobLogger) + m = ENV['BUNDLE_GEMFILE'].match(/sidekiq(?<version>\d+)/) + + case m['version'] + when '51' + expect(::Sidekiq.options[:job_logger]).to eq(Loga::Sidekiq5::JobLogger) + when '6' + expect(::Sidekiq.options[:job_logger]).to eq(Loga::Sidekiq6::JobLogger) + end end end shared_examples 'a blank change' do it 'does nothing' do