test/loggable_test.rb in semantic_logger-2.19.0 vs test/loggable_test.rb in semantic_logger-2.20.0
- old
+ new
@@ -6,15 +6,29 @@
end
# Unit Test for SemanticLogger::Appender::File
#
class AppenderFileTest < Minitest::Test
+ module Perform
+ def perform
+ logger.info 'perform'
+ end
+ end
+
class Base
include SemanticLogger::Loggable
+ include Perform
end
+ module Process
+ def process
+ logger.info 'process'
+ end
+ end
+
class Subclass < Base
+ include Process
end
describe SemanticLogger::Loggable do
describe 'inheritance' do
it 'should give child classes their own logger' do
@@ -33,9 +47,29 @@
assert_equal base.class.name, base.logger.name
assert_equal subclass.class.name, subclass.logger.name
child_logger = subclass.logger
refute_equal child_logger, base.logger
assert_equal child_logger.object_id, subclass.logger.object_id
+ end
+
+ it 'should allow mixins to call parent logger' do
+ base = Base.new
+ base.perform
+ called = false
+ Base.logger.stub(:info, -> description { called = true if description == 'perform' }) do
+ base.perform
+ end
+ assert called, 'Did not call the correct logger'
+ end
+
+ it 'should allow child mixins to call parent logger' do
+ subclass = Subclass.new
+ subclass.process
+ called = false
+ Subclass.logger.stub(:info, -> description { called = true if description == 'process' }) do
+ subclass.process
+ end
+ assert called, 'Did not call the correct logger'
end
end
describe 'logger' do
before do