Sha256: 1ae944c5c303bd9455030a62ab7ad76aadca777f543b5a9ff71f259872d2e9a5

Contents?: true

Size: 1.52 KB

Versions: 28

Compression:

Stored size: 1.52 KB

Contents

require File.expand_path(File.join(File.dirname(__FILE__), "test_helper"))

require 'onelogin/ruby-saml/logging'

class LoggingTest < Minitest::Test

  describe "Logging" do
    before do
      OneLogin::RubySaml::Logging.logger = nil
    end

    after do
      OneLogin::RubySaml::Logging.logger = ::TEST_LOGGER
    end

    describe "given no specific logging setup" do
      it "prints to stdout" do
        OneLogin::RubySaml::Logging::DEFAULT_LOGGER.expects(:debug).with('hi mom')
        OneLogin::RubySaml::Logging.debug('hi mom')
      end
    end

    describe "given a Rails app" do
      let(:logger) { mock('Logger') }

      before do
        ::Rails = mock('Rails module')
        ::Rails.stubs(:logger).returns(logger)
      end

      after do
        Object.instance_eval { remove_const(:Rails) }
      end

      it "delegates to Rails" do
        logger.expects(:debug).with('hi mom')
        logger.expects(:info).with('sup?')

        OneLogin::RubySaml::Logging.debug('hi mom')
        OneLogin::RubySaml::Logging.info('sup?')
      end
    end

    describe "given a specific Logger" do
      let(:logger) { mock('Logger') }

      before { OneLogin::RubySaml::Logging.logger = logger }

      after do
        OneLogin::RubySaml::Logging.logger = ::TEST_LOGGER
      end

      it "delegates to the object" do
        logger.expects(:debug).with('hi mom')
        logger.expects(:info).with('sup?')

        OneLogin::RubySaml::Logging.debug('hi mom')
        OneLogin::RubySaml::Logging.info('sup?')
      end
    end
  end
end

Version data entries

28 entries across 28 versions & 3 rubygems

Version Path
ruby-saml-1.11.0 test/logging_test.rb
ruby-saml-1.10.2 test/logging_test.rb
ruby-saml-1.10.1 test/logging_test.rb
ruby-saml-1.10.0 test/logging_test.rb
ruby-saml-1.9.0 test/logging_test.rb
ruby-saml-1.8.0 test/logging_test.rb
ruby-saml-1.7.2 test/logging_test.rb
ruby-saml-1.7.1 test/logging_test.rb
ruby-saml-1.6.2 test/logging_test.rb
ruby-saml-1.7.0 test/logging_test.rb
ruby-saml-1.6.1 test/logging_test.rb
ruby-saml-1.6.0 test/logging_test.rb
ruby-saml-1.5.0 test/logging_test.rb
ruby-saml-1.4.3 test/logging_test.rb
ruby-saml-1.4.2 test/logging_test.rb
ruby-saml-1.4.1 test/logging_test.rb
ruby-saml-1.4.0 test/logging_test.rb
ruby-saml-1.3.1 test/logging_test.rb
ruby-saml-1.3.0 test/logging_test.rb
ruby-saml-1.2.0 test/logging_test.rb