1
0
mirror of https://github.com/meineerde/rackstash.git synced 2026-01-31 17:27:13 +00:00

Add empty? predicate to Fields::Array

This commit is contained in:
Holger Just 2017-02-02 21:49:07 +01:00
parent e69818dd01
commit b91a31335a
4 changed files with 28 additions and 0 deletions

View File

@ -39,6 +39,10 @@ module Rackstash
self
end
def empty?
@raw.empty?
end
def length
@raw.length
end

View File

@ -45,6 +45,10 @@ module Rackstash
self
end
def empty?
@raw.empty?
end
def keys
@raw.keys
end

View File

@ -123,6 +123,16 @@ describe Rackstash::Fields::Array do
end
end
describe '#empty?' do
it 'returns true of there are any tags' do
expect(array.empty?).to be true
array[0] = 'foo'
expect(array.empty?).to be false
array.clear
expect(array.empty?).to be true
end
end
describe '#length' do
it 'returns the length of the array' do
expect(array.length).to eql 0

View File

@ -160,6 +160,16 @@ describe Rackstash::Fields::Hash do
end
end
describe '#empty?' do
it 'returns true of there are any fields' do
expect(hash.empty?).to be true
hash['key'] = 'foo'
expect(hash.empty?).to be false
hash.clear
expect(hash.empty?).to be true
end
end
describe '#forbidden_key?' do
let(:forbidden_keys) { ['forbidden', :foo] }