Skip to content
This repository
Fetching contributors…

Cannot retrieve contributors at this time

file 36 lines (28 sloc) 1.039 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
require File.expand_path '../helper', __FILE__

require 'airbrake/rails'

class RailsInitializerTest < Test::Unit::TestCase
  include DefinesConstants

  should "trigger use of Rails' logger if logger isn't set and Rails' logger exists" do
    rails = Module.new do
      def self.logger
        "RAILS LOGGER"
      end
    end
    define_constant("Rails", rails)
    Airbrake::Rails.initialize
    assert_equal "RAILS LOGGER", Airbrake.logger
  end

  should "trigger use of Rails' default logger if logger isn't set and Rails.logger doesn't exist" do
    define_constant("RAILS_DEFAULT_LOGGER", "RAILS DEFAULT LOGGER")

    Airbrake::Rails.initialize
    assert_equal "RAILS DEFAULT LOGGER", Airbrake.logger
  end

  should "allow overriding of the logger if already assigned" do
    define_constant("RAILS_DEFAULT_LOGGER", "RAILS DEFAULT LOGGER")
    Airbrake::Rails.initialize

    Airbrake.configure(true) do |config|
      config.logger = "OVERRIDDEN LOGGER"
    end

    assert_equal "OVERRIDDEN LOGGER", Airbrake.logger
  end
end
Something went wrong with that request. Please try again.