Sha256: f2e591feb78b63990392a648f954b647b9d70e4eb7486b1e60f410575c6b6029

Contents?: true

Size: 1.55 KB

Versions: 6

Compression:

Stored size: 1.55 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(:force)     { false }
      let(:type)      { :info }

      describe '.log' do
        subject { described.log(message: _message, force: force, type: type) }

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

          it { subject.must_equal(expected) }
        end

        context 'when :force is false' do
          let(:force) { 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

6 entries across 6 versions & 1 rubygems

Version Path
vedeu-0.8.14 test/lib/vedeu/logging/log_test.rb
vedeu-0.8.13 test/lib/vedeu/logging/log_test.rb
vedeu-0.8.12 test/lib/vedeu/logging/log_test.rb
vedeu-0.8.10 test/lib/vedeu/logging/log_test.rb
vedeu-0.8.9 test/lib/vedeu/logging/log_test.rb
vedeu-0.8.8 test/lib/vedeu/logging/log_test.rb