1
0
mirror of https://github.com/meineerde/rackstash.git synced 2025-10-17 14:01:01 +00:00
rackstash/spec/rackstash_spec.rb
Holger Just d07a9452f4 Add Rackstash::UNDEFINED constant
The {UNDEFINED} object can be used as the default value for method
arguments to distinguish it from `nil`. See
https://holgerjust.de/2016/detecting-default-arguments-in-ruby/#special-default-value
for details.
2017-07-11 23:42:13 +02:00

57 lines
1.7 KiB
Ruby

# Copyright 2017 Holger Just
#
# This software may be modified and distributed under the terms
# of the MIT license. See the LICENSE.txt file for details.
require 'spec_helper'
describe Rackstash do
it 'defines PROGRAME with the correct version' do
expect(Rackstash::PROGNAME).to match %r{\Arackstash/v\d+(\..+)*\z}
expect(Rackstash::PROGNAME).to be_frozen
end
it 'defines SEVERITIES constants' do
expect(Rackstash::SEVERITIES).to eql((0..5).to_a)
expect(Rackstash::DEBUG).to eql 0
expect(Rackstash::INFO).to eql 1
expect(Rackstash::WARN).to eql 2
expect(Rackstash::ERROR).to eql 3
expect(Rackstash::FATAL).to eql 4
expect(Rackstash::UNKNOWN).to eql 5
end
it 'defines EMPTY_* constants' do
expect(Rackstash::EMPTY_STRING).to eql ''
expect(Rackstash::EMPTY_STRING).to be_frozen
expect(Rackstash::EMPTY_SET).to eql Set.new
expect(Rackstash::EMPTY_SET).to be_frozen
expect(Rackstash::ISO8601_PRECISION).to be_a Integer
end
it 'defines FIELD_* constants' do
constants = Rackstash.constants.select { |c| c.to_s.start_with?('FIELD_') }
expect(constants).not_to be_empty
constants.each do |name|
expect(Rackstash.const_get(name)).to be_a String
expect(Rackstash.const_get(name)).to be_frozen
end
end
it 'defines UNDEFINED' do
expect(Rackstash::UNDEFINED).to be_instance_of Rackstash::UndefinedClass
expect(Rackstash::UNDEFINED.to_s).to eql 'undefined'
expect(Rackstash::UNDEFINED).to equal Rackstash::UNDEFINED
expect(Rackstash::UNDEFINED).not_to eql nil
expect(Rackstash::UNDEFINED).not_to eql false
expect(Rackstash::UNDEFINED).not_to eql true
expect(Rackstash::UNDEFINED).not_to eql 42
end
end