Sha256: da99dc617ff3c14dec952e46abda636836abf792955f18dc645ad1dc0848fabd

Contents?: true

Size: 1.45 KB

Versions: 591

Compression:

Stored size: 1.45 KB

Contents

#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../test_helper'
require 'pathname'

class LoggerTest < Test::Unit::TestCase

  class InterceptedLogger < Sass::Logger::Base

    attr_accessor :messages

    def initialize(*args)
      super
      self.messages = []
    end

    def reset!
      self.messages = []
    end

    def _log(*args)
      messages << [args]
    end

  end

  def test_global_sass_logger_instance_exists
    assert Sass.logger.respond_to?(:warn)
  end

  def test_log_level_orders
    logged_levels = {
      :trace => [ [], [:trace, :debug, :info, :warn, :error]],
      :debug => [ [:trace],   [:debug, :info, :warn, :error]],
      :info  => [ [:trace, :debug],   [:info, :warn, :error]],
      :warn  => [ [:trace, :debug, :info],   [:warn, :error]],
      :error => [ [:trace, :debug, :info, :warn],   [:error]]
    }
    logged_levels.each do |level, (should_not_be_logged, should_be_logged)|
      logger = Sass::Logger::Base.new(level)
      should_not_be_logged.each do |should_level|
        assert !logger.logging_level?(should_level)
      end
      should_be_logged.each do |should_level|
        assert logger.logging_level?(should_level)
      end
    end
  end

  def test_logging_can_be_disabled
    logger = InterceptedLogger.new
    logger.error("message #1")
    assert_equal 1, logger.messages.size
    logger.reset!
    logger.disabled = true
    logger.error("message #2")
    assert_equal 0, logger.messages.size
  end
end

Version data entries

591 entries across 305 versions & 16 rubygems

Version Path
mango-0.7.1 vendor/bundler/ruby/2.0.0/gems/sass-3.2.12/test/sass/logger_test.rb
sass-3.2.13 test/sass/logger_test.rb
mango-0.7.0 vendor/bundler/ruby/2.0.0/gems/sass-3.2.12/test/sass/logger_test.rb
sass-3.3.0.rc.2 test/sass/logger_test.rb
sass-3.3.0.rc.1 test/sass/logger_test.rb
sass-3.3.0.alpha.392 test/sass/logger_test.rb
sass-3.3.0.alpha.391 test/sass/logger_test.rb
sass-3.3.0.alpha.390 test/sass/logger_test.rb
sass-3.3.0.alpha.389 test/sass/logger_test.rb
sass-3.3.0.alpha.388 test/sass/logger_test.rb
sass-3.3.0.alpha.382 test/sass/logger_test.rb
sass-3.3.0.alpha.380 test/sass/logger_test.rb
sass-3.3.0.alpha.378 test/sass/logger_test.rb
sass-3.3.0.alpha.377 test/sass/logger_test.rb
sass-3.3.0.alpha.376 test/sass/logger_test.rb
sass-3.3.0.alpha.375 test/sass/logger_test.rb
sass-3.3.0.alpha.372 test/sass/logger_test.rb
sass-3.3.0.alpha.370 test/sass/logger_test.rb
sass-3.3.0.alpha.369 test/sass/logger_test.rb
sass-3.3.0.alpha.368 test/sass/logger_test.rb