module Boty RSpec.describe Logger do class Client; include Logger end let(:logger) { Boty::Logger } let(:client) { Client.new } describe ".adapter" do it "changes the internal logger representation" do memory_logger = Boty::Logger::Memory.new logger.adapter = memory_logger expect(memory_logger).to receive(:info).with "hello" client.logger.info "hello" end end describe "#logger" do it "returns the current adapter" do memory_logger = Boty::Logger::Memory.new logger.adapter = memory_logger expect(client.logger).to eq memory_logger end end describe Logger::Multi do let(:adapter1) { double } let(:adapter2) { double } subject(:multi) { described_class.new [adapter1, adapter2] } describe "#add" do it "delegates the #add invocation to the underlying adapters" do expect(adapter1).to receive(:add).with("omg", "lol") expect(adapter2).to receive(:add).with("omg", "lol") multi.add("omg", "lol") end end describe "#level=" do it "delegates the #level= invocation to the underlying adapters" do expect(adapter1).to receive(:level=).with(::Logger::INFO) expect(adapter2).to receive(:level=).with(::Logger::INFO) multi.level = ::Logger::INFO end end end describe Logger::Memory do subject(:adapter) { described_class.new } before do logger.adapter = adapter end it "stores the logs in memory" do client.logger.info "hello" expect(adapter.logs.last).to eq "hello" end end end end