mirror of
https://github.com/meineerde/rackstash.git
synced 2025-12-19 15:01:12 +00:00
Test all conditions of Rackstash::Fields::Hash()
This commit is contained in:
parent
b72b8cf94b
commit
b6768c6547
@ -727,14 +727,21 @@ describe Rackstash::Fields::Hash do
|
|||||||
raw = { :time => Time.now, 'string' => 'foo' }
|
raw = { :time => Time.now, 'string' => 'foo' }
|
||||||
hash = Rackstash::Fields::Hash(raw)
|
hash = Rackstash::Fields::Hash(raw)
|
||||||
|
|
||||||
expect(hash).to be_instance_of Rackstash::Fields::Hash
|
expect(hash).to be_instance_of described_class
|
||||||
expect(hash['time']).to be_a String
|
expect(hash['time']).to be_a String
|
||||||
expect(hash['string']).to eql 'foo'
|
expect(hash['string']).to eql 'foo'
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'can specify forbidden_keys' do
|
it 'can specify forbidden_keys' do
|
||||||
|
raw = { foo: :bar }
|
||||||
|
hash = Rackstash::Fields::Hash(raw, forbidden_keys: ['forbidden'])
|
||||||
|
|
||||||
|
expect { hash['forbidden'] = 'wut?' }.to raise_error ArgumentError
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'applies forbidden_keys on first assignment' do
|
||||||
raw = { foo: :bar, forbidden: 'ignored' }
|
raw = { foo: :bar, forbidden: 'ignored' }
|
||||||
expect { Rackstash::Fields::Hash(raw, forbidden_fields: ['forbidden']) }
|
expect { Rackstash::Fields::Hash(raw, forbidden_keys: ['forbidden']) }
|
||||||
.to raise_error ArgumentError
|
.to raise_error ArgumentError
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user