Sha256: 7ef7b74c8036c1df95ac780e1e62c25efa5eb834ec2e724db9d951aca6a7c52c

Contents?: true

Size: 1.58 KB

Versions: 13

Compression:

Stored size: 1.58 KB

Contents

# frozen_string_literal: true

require 'test_helper'

module Vedeu

  describe 'Bindings' do
    it { Vedeu.bound?(:_log_).must_equal(true) }
  end

  module Logging

    describe Log do

      let(:described) { Vedeu::Logging::Log }
      let(:_message)  { 'Some message...' }
      let(:type)      { :info }

      describe '.log' do
        before { Vedeu.config.stubs(:log?).returns(enabled) }

        subject { described.log(message: _message, type: type) }

        context 'when the log is enabled' do
          let(:enabled)  { true }
          let(:expected) {
            "\e[97m[info]     \e[39m\e[37mSome message...\e[39m"
          }

          it { subject.must_equal(expected) }
        end

        context 'when the log is disabled' do
          let(:enabled)  { false }

          it { subject.must_equal(nil) }
        end
      end

      describe '.log_stdout' do
        let(:type)     { :create }
        let(:_message) { 'Logging to stdout...' }

        subject { described.log_stdout(type: type, message: _message) }

        it do
          capture_io { subject }.must_equal(
            ["\e[96m[create]   \e[39m\e[36mLogging to stdout...\e[39m\n", ""]
          )
        end
      end

      describe '.log_stderr' do
        let(:type)     { :debug }
        let(:_message) { 'Logging to stderr...' }

        subject { described.log_stderr(type: type, message: _message) }

        it do
          capture_io { subject }.must_equal(
            ["", "\e[97m[debug]    \e[39m\e[37mLogging to stderr...\e[39m\n"]
          )
        end
      end

    end # Log

  end # Logging

end # Vedeu

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
vedeu-0.8.27 test/lib/vedeu/logging/log_test.rb
vedeu-0.8.26 test/lib/vedeu/logging/log_test.rb
vedeu-0.8.25 test/lib/vedeu/logging/log_test.rb
vedeu-0.8.24 test/lib/vedeu/logging/log_test.rb
vedeu-0.8.23 test/lib/vedeu/logging/log_test.rb
vedeu-0.8.22 test/lib/vedeu/logging/log_test.rb
vedeu-0.8.21 test/lib/vedeu/logging/log_test.rb
vedeu-0.8.20 test/lib/vedeu/logging/log_test.rb
vedeu-0.8.19 test/lib/vedeu/logging/log_test.rb
vedeu-0.8.18 test/lib/vedeu/logging/log_test.rb
vedeu-0.8.17 test/lib/vedeu/logging/log_test.rb
vedeu-0.8.16 test/lib/vedeu/logging/log_test.rb
vedeu-0.8.15 test/lib/vedeu/logging/log_test.rb