lib/submodules/ably-ruby/spec/unit/logger_spec.rb in ably-rest-1.0.6 vs lib/submodules/ably-ruby/spec/unit/logger_spec.rb in ably-rest-1.1.0

- old
+ new

@@ -15,15 +15,19 @@ it 'uses the language provided Logger by default' do expect(subject.logger).to be_a(Logger) end context 'internals', :api_private do - it 'delegates to the logger object' do - expect(subject.logger).to receive(:warn) do |*args, &block| + it 'delegates to the default Logger object' do + received = false + expect(subject.logger).to be_a(::Logger) + allow_any_instance_of(::Logger).to receive(:warn) do |*args, &block| expect(args.concat([block ? block.call : nil]).join(',')).to match(/message/) + received = true end subject.warn 'message' + expect(received).to be_truthy end context 'formatter' do context 'when debugging' do it 'uses short time format' do @@ -130,13 +134,16 @@ expect { subject }.to_not raise_error expect(subject.logger.class).to eql(custom_logger) end it 'delegates log messages to logger', :api_private do - expect(custom_logger_object).to receive(:fatal) do |*args, &block| + received = false + allow(custom_logger_object).to receive(:fatal) do |*args, &block| expect(args.concat([block ? block.call : nil]).join(',')).to match(/message/) + received = true end subject.fatal 'message' + expect(received).to be_truthy end end end context 'with blocks', :prevent_log_stubbing do