require 'spec_helper' describe LiveQA::FormatedLogger do let(:default_logger) { Logger.new(STDOUT) } let(:logger) { LiveQA::FormatedLogger.build(default_logger) } describe 'debug' do context 'active' do before do allow(default_logger).to receive(:debug) logger.debug('test') end it { expect(default_logger).to have_received(:debug).with('[LiveQA] test') } end context 'inactive' do before do LiveQA.configurations.log = false allow(default_logger).to receive(:debug) logger.debug('test') end it { expect(default_logger).to_not have_received(:debug) } end end describe 'info' do context 'active' do before do allow(default_logger).to receive(:info) logger.info('test') end it { expect(default_logger).to have_received(:info).with('[LiveQA] test') } end context 'inactive' do before do LiveQA.configurations.log = false allow(default_logger).to receive(:info) logger.info('test') end it { expect(default_logger).to_not have_received(:info) } end end describe 'info' do context 'active' do before do allow(default_logger).to receive(:info) logger.info('test') end it { expect(default_logger).to have_received(:info).with('[LiveQA] test') } end context 'inactive' do before do LiveQA.configurations.log = false allow(default_logger).to receive(:info) logger.info('test') end it { expect(default_logger).to_not have_received(:info) } end end describe 'error' do context 'active' do before do allow(default_logger).to receive(:error) logger.error('test') end it { expect(default_logger).to have_received(:error).with('[LiveQA] test') } end context 'inactive' do before do LiveQA.configurations.log = false allow(default_logger).to receive(:error) logger.error('test') end it { expect(default_logger).to_not have_received(:error) } end end end