Sha256: f263b5aad86ce5e23ae9d545e29778acb000cf0b956cbbeb60d59154d180b80b
Contents?: true
Size: 1.47 KB
Versions: 2
Compression:
Stored size: 1.47 KB
Contents
# frozen_string_literal: true require 'spec_helper' RSpec.describe(Fuli) do let!(:logger_mock) { double("Mocked.logger").as_null_object } let(:warn_proc) { proc { |error, message| } } let(:error_proc) { proc { |error, message| } } before do allow(logger_mock).to receive(:warn).and_return(true) allow(logger_mock).to receive(:error).and_return(true) end let!(:config) do Fuli.configure do |config| config.logger = logger_mock config.warn_notifiers = [warn_proc] config.error_notifiers = [error_proc] end end describe '.notify_warning' do let(:error) { StandardError.new('Error message') } let(:message) { 'More specific message' } after { Fuli.notify_warning(error, message) } it 'calls logger with correct level' do expect(logger_mock).to receive(:warn) end it 'calls warn notifiers' do expect(warn_proc).to receive(:call).with(error, message) end end describe '.notify_error' do let(:error) { StandardError.new('Error message') } let(:message) { 'More specific message' } after { Fuli.notify_error(error, message) } it 'calls logger with correct level' do expect(logger_mock).to receive(:error) end it 'calls warn notifiers' do expect(error_proc).to receive(:call).with(error, message) end end context 'when no logger defined' do it 'raises error' do expect { Fuli.configure { |c| c.logger = nil } }.to raise_error(Fuli::Error) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
fuli_the_guard-0.1.1 | spec/fuli_spec.rb |
fuli_the_guard-0.1.0 | spec/fuli_spec.rb |