Sha256: c31cbdd0c17e8bcf0f92c5a81d32dc75245fb3547f1809175b163909bda899a7

Contents?: true

Size: 1.16 KB

Versions: 31

Compression:

Stored size: 1.16 KB

Contents

require 'spec_helper'

describe Betterlog::Log::Severity do
  it 'has all constants' do
    expect(described_class.all.map(&:to_s).sort).to\
      eq %w[ WARN ERROR FATAL UNKNOWN DEBUG INFO ].sort
  end

  it 'resolves unknown severities to UNKNOWN' do
    expect(described_class.new('NIX')).to eq(described_class.new(:UNKNOWN))
  end

  context 'severity instance' do
    subject do
      described_class.new('error')
    end

    it 'can be converted to integer' do
      expect(subject.to_i).to eq 3
    end

    it 'can be converted to symbol' do
      expect(subject.to_sym).to eq :error
    end

    it 'can be converted to string' do
      expect(subject.to_s).to eq 'ERROR'
    end

    it 'can be converted to json' do
      expect(subject.to_json).to eq '"ERROR"'
    end

    it 'can be converted via as_json' do
      expect(subject.as_json).to eq 'ERROR'
    end

    it 'can be compared by level' do
      expect(subject).to be < described_class.new(:FATAL)
    end

    it 'can be compared by level via symbol' do
      expect(subject).to be < :FATAL
    end

    it 'implements hash depending on name symbol' do
      expect(subject.hash).to eq :error.hash
    end
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
betterlog-2.0.4 spec/betterlog/log/severity_spec.rb
betterlog-2.0.3 spec/betterlog/log/severity_spec.rb
betterlog-2.0.2 spec/betterlog/log/severity_spec.rb
betterlog-2.0.1 spec/betterlog/log/severity_spec.rb
betterlog-2.0.0 spec/betterlog/log/severity_spec.rb
betterlog-1.1.1 spec/betterlog/log/severity_spec.rb
betterlog-1.1.0 spec/betterlog/log/severity_spec.rb
betterlog-1.0.0 spec/betterlog/log/severity_spec.rb
betterlog-0.20.3 spec/betterlog/log/severity_spec.rb
betterlog-0.20.2 spec/betterlog/log/severity_spec.rb
betterlog-0.20.1 spec/betterlog/log/severity_spec.rb
betterlog-0.20.0 spec/betterlog/log/severity_spec.rb
betterlog-0.19.0 spec/betterlog/log/severity_spec.rb
betterlog-0.18.0 spec/betterlog/log/severity_spec.rb
betterlog-0.15.2 spec/betterlog/log/severity_spec.rb
betterlog-0.15.1 spec/betterlog/log/severity_spec.rb
betterlog-0.15.0 spec/betterlog/log/severity_spec.rb
betterlog-0.14.1 spec/betterlog/log/severity_spec.rb
betterlog-0.14.0 spec/betterlog/log/severity_spec.rb
betterlog-0.13.1 spec/betterlog/log/severity_spec.rb