Sha256: 624de9c2b723da6eae968fd05d18c89cef39cd50411a59868b2dbee3e6f1c4f8

Contents?: true

Size: 1.75 KB

Versions: 31

Compression:

Stored size: 1.75 KB

Contents

require_relative '../../test_helper'

# Unit Test for RocketJob::Job
module Plugins
  module Job
    class LoggerTest < Minitest::Test

      class LoggerJob < RocketJob::Job
        def perform
          logger.debug('DONE', value: 123, other_value: 'HI')
        end
      end

      describe RocketJob::Plugins::Job::Logger do
        before do
          LoggerJob.delete_all
        end

        after do
          @job.destroy if @job && !@job.new_record?
          SemanticLogger.flush
        end

        describe '#logger' do
          it 'uses semantic logger' do
            @job = LoggerJob.new
            assert_kind_of SemanticLogger::Logger, @job.logger, @job.logger.ai
            assert_equal @job.class.name, @job.logger.name, @job.logger.ai
          end

          it 'allows perform to log its own data' do
            @job = LoggerJob.new
            @job.perform_now
          end

          it 'adds start logging' do
            @job        = LoggerJob.new
            info_called = false
            @job.logger.stub(:info, -> description { info_called = true if description == 'Start #perform' }) do
              @job.perform_now
            end
            assert info_called, "In Plugins::Job::Logger.around_perform logger.info('Start #perform') not called"
          end

          it 'adds completed logging' do
            @job           = LoggerJob.new
            measure_called = false
            @job.logger.stub(:measure_info, -> description, *args { measure_called = true if description == 'Completed #perform' }) do
              @job.perform_now
            end
            assert measure_called, "In Plugins::Job::Logger.around_perform logger.measure_info('Completed #perform') not called"
          end
        end

      end
    end
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
rocketjob-3.0.0.rc3 test/plugins/job/logger_test.rb
rocketjob-3.0.0.rc2 test/plugins/job/logger_test.rb
rocketjob-3.0.0.rc1 test/plugins/job/logger_test.rb
rocketjob-3.0.0.beta3 test/plugins/job/logger_test.rb
rocketjob-3.0.0.beta2 test/plugins/job/logger_test.rb
rocketjob-3.0.0.beta test/plugins/job/logger_test.rb
rocketjob-3.0.0.alpha test/plugins/job/logger_test.rb
rocketjob-2.1.3 test/plugins/job/logger_test.rb
rocketjob-2.1.2 test/plugins/job/logger_test.rb
rocketjob-2.1.1 test/plugins/job/logger_test.rb
rocketjob-2.0.0 test/plugins/job/logger_test.rb