Sha256: f1d1f48ce1c0c6e76cb6eaac21b09658b624888313aac6b3b656859151640795

Contents?: true

Size: 1.15 KB

Versions: 8

Compression:

Stored size: 1.15 KB

Contents

# frozen_string_literal: true

RSpec.describe YARD::Logger do
  describe "#show_backtraces" do
    it "is true if debug level is on" do
      log.show_backtraces = true
      log.enter_level(Logger::DEBUG) do
        log.show_backtraces = false
        expect(log.show_backtraces).to be true
      end
      expect(log.show_backtraces).to be false
    end
  end

  describe "#backtrace" do
    before { log.show_backtraces = true }
    after  { log.show_backtraces = false }

    it "logs backtrace in error by default" do
      expect(log).to receive(:error).with("RuntimeError: foo")
      expect(log).to receive(:error).with("Stack trace:\n\tline1\n\tline2\n")
      exc = RuntimeError.new("foo")
      exc.set_backtrace(['line1', 'line2'])
      log.enter_level(Logger::INFO) { log.backtrace(exc) }
    end

    it "allows backtrace to be entered in other modes" do
      expect(log).to receive(:warn).with("RuntimeError: foo")
      expect(log).to receive(:warn).with("Stack trace:\n\tline1\n\tline2\n")
      exc = RuntimeError.new("foo")
      exc.set_backtrace(['line1', 'line2'])
      log.enter_level(Logger::INFO) { log.backtrace(exc, :warn) }
    end
  end
end

Version data entries

8 entries across 7 versions & 4 rubygems

Version Path
yard-0.9.9 spec/logging_spec.rb
etude_for_ruby-0.1.4 vendor/bundle/ruby/2.4.0/gems/yard-0.9.8/spec/logging_spec.rb
etude_for_ruby-0.1.4 vendor/bundle/ruby/2.2.0/gems/yard-0.9.8/spec/logging_spec.rb
mdg-1.0.1 vendor/bundle/ruby/2.3.0/gems/yard-0.9.8/spec/logging_spec.rb
yard-0.9.8 spec/logging_spec.rb
abaci-0.3.0 vendor/bundle/gems/yard-0.9.7/spec/logging_spec.rb
yard-0.9.7 spec/logging_spec.rb
yard-0.9.6 spec/logging_spec.rb