Sha256: f7e82501bd773d042ea3b6bde7ac4858741e7dcd2667025956a5263f0b00d7c0

Contents?: true

Size: 1.34 KB

Versions: 4

Compression:

Stored size: 1.34 KB

Contents

require 'rails_helper'

module BerkeleyLibrary
  module Logging
    describe Railtie do
      attr_reader :app
      attr_reader :config

      before do
        @app = Class.new(Rails::Application).new
        allow(Rails).to receive(:application).and_return(app)
        @config = app.config
      end

      describe 'initializer' do
        attr_reader :logging_initializer
        attr_reader :bootstrap_logger_initializer

        before do
          expected_file, _line = Module.const_source_location(BerkeleyLibrary::Logging::Railtie.name)
          @logging_initializer = app.initializers.find do |init|
            block = init.block
            file, _line = block.source_location
            file == expected_file
          end
          @bootstrap_logger_initializer = app.initializers.find { |init| init.name == :initialize_logger }
        end

        it 'is added to the Rails application' do
          expect(logging_initializer).not_to be_nil
        end

        it 'runs before the bootstrap logger initializer' do
          expect(logging_initializer.before).to eq(bootstrap_logger_initializer.name)
        end

        it 'sets the logger' do
          logging_initializer.run(app)
          bootstrap_logger_initializer.run(app)

          expect(Rails.logger).to be_a(BerkeleyLibrary::Logging::Logger)
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
berkeley_library-logging-0.2.7 spec/rails/ucblit/logging/railtie_spec.rb
berkeley_library-logging-0.2.6.2 spec/rails/ucblit/logging/railtie_spec.rb
berkeley_library-logging-0.2.6.1 spec/rails/ucblit/logging/railtie_spec.rb
berkeley_library-logging-0.2.6 spec/rails/ucblit/logging/railtie_spec.rb