Sha256: b45474ebb72e1d241ade89bb002b8a8fdf205f94e8811b1cd48ad0d20d40f541

Contents?: true

Size: 1.09 KB

Versions: 4

Compression:

Stored size: 1.09 KB

Contents

require 'rails/all'
require 'logstash-logger'
require 'logstash-logger/railtie'

module Test
  class Application < ::Rails::Application
    config.eager_load = false

    config.logstash.port = PORT
    config.log_level = :info
  end
end

Test::Application.initialize!

describe LogStashLogger do
  describe "Rails integration" do
    let(:app) { Rails.application }
    let(:config) { app.config }

    describe 'Railtie' do
      describe 'Rails.logger' do
        subject { Rails.logger }

        it { should be_a LogStashLogger }

        it "defaults level to config.log_level" do
          expect(subject.level).to eq(::Logger::INFO)
        end
      end
    end

    describe '#setup' do
      before do
        app.config.logstash.port = PORT
        LogStashLogger.setup(app)
      end

      context "when logstash is not configured" do
        before do
          app.config.logstash.clear
          app.config.logger = nil
          LogStashLogger.setup(app)
        end

        it "does not configure anything" do
          expect(app.config.logger).to be_nil
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
logstash-logger-0.6.2 spec/rails_spec.rb
logstash-logger-0.6.1 spec/rails_spec.rb
logstash-logger-0.6.0 spec/rails_spec.rb
logstash-logger-0.5.0 spec/rails_spec.rb