spec/betterlog/global_metadata_spec.rb in betterlog-0.20.2 vs spec/betterlog/global_metadata_spec.rb in betterlog-0.20.3

- old
+ new

@@ -1,16 +1,18 @@ require 'spec_helper' describe Betterlog::GlobalMetadata do - let :notifier do - Class.new do - def notify(message, hash) end + class FakeNotifierClass + def notify(message, hash) end - def context(data_hash) end - end.new + def context(data_hash) end end + let :notifier do + FakeNotifierClass.new + end + around do |example| Betterlog::Notifiers.register(notifier) example.run ensure Betterlog::Notifiers.notifiers.clear @@ -25,14 +27,14 @@ described_class.data |= { foo: 'bar' } expect(described_class.data).to eq({ foo: 'bar' }) end it 'can "add" data' do - expect(notifier).to receive(:context).with(foo: 'bar') + expect_any_instance_of(FakeNotifierClass).to receive(:context).with(foo: 'bar') expect(described_class.add(foo: 'bar')).to eq described_class.instance end it 'can "add" data via Log.context' do - expect(notifier).to receive(:context).with(foo: 'bar') + expect_any_instance_of(FakeNotifierClass).to receive(:context).with(foo: 'bar') Betterlog::Log.context(foo: 'bar') end end