Sha256: d08a157370a39ef9e29c27288edd328b3681c4776adb572ee1e21b62f42ef7f6

Contents?: true

Size: 969 Bytes

Versions: 2

Compression:

Stored size: 969 Bytes

Contents

require 'test_helper'
require 'logger'
require 'loggr/lint'
require 'loggr/adapter'
require 'loggr/adapter/rails'

# mock Rails
module MockRails
  def self.logger
    @logger ||= ::Logger.new('/dev/null')
  end
end

class Loggr::Adapter::RailsTest < MiniTest::Unit::TestCase
  def setup
    Object.send(:remove_const, :Rails) if Object.const_defined?(:Rails)
    Object.const_set(:Rails, ::MockRails)
    @adapter = Loggr::Adapter::RailsAdapter.new
  end

  include Loggr::Lint::Tests

  def test_rails_should_be_a_rails_adapter
    assert_kind_of Loggr::Adapter::RailsAdapter, Loggr::Adapter::Rails
  end

  def test_should_use_same_logger_as_rails
    @logger = Loggr::Adapter::Rails.logger('log')
    assert_equal ::Rails.logger, as_3_2? ? @logger.instance_variable_get('@logger') : @logger
  end

  def test_should_default_to_rails_adapter
    clazz = Class.new do
      extend Loggr::Adapter
    end

    assert_equal Loggr::Adapter::Rails, clazz.adapter
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
loggr-1.1.2 test/unit/adapter/rails_test.rb
loggr-1.1.1 test/unit/adapter/rails_test.rb