Sha256: 3106d0c6b18920fc7d81f950063e9f4541bd674e957ef3b2107c1979a8c81ac6

Contents?: true

Size: 1.1 KB

Versions: 4

Compression:

Stored size: 1.1 KB

Contents

require File.expand_path '../helper', __FILE__

require 'projectlocker_errata/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)
    ProjectlockerErrata::Rails.initialize
    assert_equal "RAILS LOGGER", ProjectlockerErrata.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")

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

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

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

    assert_equal "OVERRIDDEN LOGGER", ProjectlockerErrata.logger
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
projectlocker_errata-0.1.1 test/rails_initializer_test.rb
projectlocker_errata-0.1.0 test/rails_initializer_test.rb
projectlocker_errata-0.0.2 test/rails_initializer_test.rb
projectlocker_errata-0.0.1 test/rails_initializer_test.rb