Sha256: 67428a9602fa89b9e1b9376c7781ef4fece34fac5425e4760333d34766b2cd8c

Contents?: true

Size: 953 Bytes

Versions: 2

Compression:

Stored size: 953 Bytes

Contents

require 'spec_helper'

describe Alephant::Logger do
  describe ".get_logger" do

    context "no logger set" do
      specify {
        expect(subject.get_logger.logger).to be_a Logger
      }
    end

    context "subject.set_logger(:foo)" do
      it "returns @@logger" do
        subject.class_variable_set(:@@logger, :foo)
        expect(subject.get_logger).to eq(:foo)
      end
    end
  end

  describe ".set_logger(:foo)" do
    it "sets foo as @@logger" do
      subject.set_logger(:bar)
      expect(subject.class_variable_get(:@@logger).logger).to eq :bar
    end
  end

  context "when included in a class" do

    class IncludesLog
      include Alephant::Logger

      def calls_logger
        logger
      end
    end

    context "called via '#logger'" do
      it "returns the value of @@logger" do
        subject.class_variable_set(:@@logger, :baz)
        expect(IncludesLog.new.calls_logger).to eq :baz
      end
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
alephant-logger-0.2.0 spec/logger_spec.rb
alephant-logger-0.1.0 spec/logger_spec.rb