lib/submodules/ably-ruby/spec/unit/logger_spec.rb in ably-rest-1.2.0 vs lib/submodules/ably-ruby/spec/unit/logger_spec.rb in ably-rest-1.2.1
- old
+ new
@@ -1,8 +1,8 @@
require 'spec_helper'
-describe Ably::Logger do
+describe Ably::Logger, :prevent_log_stubbing do
let(:rest_client) do
instance_double('Ably::Rest::Client')
end
subject { Ably::Logger.new(rest_client, Logger::INFO) }
@@ -16,18 +16,14 @@
expect(subject.logger).to be_a(Logger)
end
context 'internals', :api_private do
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
+ expect(subject.logger).to receive(:warn).with('message')
+
subject.warn 'message'
- expect(received).to be_truthy
end
context 'formatter' do
context 'when debugging' do
it 'uses short time format' do
@@ -134,21 +130,17 @@
expect { subject }.to_not raise_error
expect(subject.logger.class).to eql(custom_logger)
end
it 'delegates log messages to logger', :api_private do
- 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
+ expect(custom_logger_object).to receive(:fatal).with('message')
+
subject.fatal 'message'
- expect(received).to be_truthy
end
end
end
- context 'with blocks', :prevent_log_stubbing do
+ context 'with blocks' do
it 'does not call the block unless the log level is met' do
log_level_blocks = []
subject.warn { log_level_blocks << :warn }
subject.info { log_level_blocks << :info }
subject.debug { log_level_blocks << :debug }