mirror of
https://github.com/meineerde/rackstash.git
synced 2025-12-19 15:01:12 +00:00
Add specs for handling of nested procs inside arrays with fields
This commit is contained in:
parent
bd376af884
commit
8232d139f4
@ -309,6 +309,27 @@ describe Rackstash::Fields::AbstractCollection do
|
|||||||
expect(normalize(array, scope: scope)[1][1]).to eql scope
|
expect(normalize(array, scope: scope)[1][1]).to eql scope
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'resolves a proc returning an array' do
|
||||||
|
expect(normalize(-> { ['foo'] })).to be_instance_of Rackstash::Fields::Array
|
||||||
|
expect(normalize(-> { ['foo'] })).to contain_exactly 'foo'
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'resolves nested procs' do
|
||||||
|
expect(normalize(-> { [-> { 'foo' } ] })).to be_instance_of Rackstash::Fields::Array
|
||||||
|
expect(normalize(-> { [-> { 'foo' } ] })).to contain_exactly 'foo'
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
it 'returns a raw array returned from a proc with wrap: false' do
|
||||||
|
expect(normalize(-> { ['foo'] }, wrap: false )).to be_a ::Array
|
||||||
|
expect(normalize(-> { ['foo'] }, wrap: false)).to eql ['foo']
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'returns a raw array returned from a nested proc with wrap: false' do
|
||||||
|
expect(normalize(-> { [-> { 'foo' }] }, wrap: false )).to be_a ::Array
|
||||||
|
expect(normalize(-> { [-> { 'foo' }] }, wrap: false)).to eql ['foo']
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'wraps an Enumerator in a Rackstash::Fields::Array' do
|
it 'wraps an Enumerator in a Rackstash::Fields::Array' do
|
||||||
|
|||||||
@ -139,6 +139,10 @@ describe Rackstash::Fields::Array do
|
|||||||
expect { array.concat(false) }.to raise_error TypeError
|
expect { array.concat(false) }.to raise_error TypeError
|
||||||
expect { array.concat(nil) }.to raise_error TypeError
|
expect { array.concat(nil) }.to raise_error TypeError
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'resolves nested procs' do
|
||||||
|
expect(array.concat(-> { [-> { :foo } ] } )).to contain_exactly 'foo'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#empty?' do
|
describe '#empty?' do
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user