mirror of
https://github.com/inspec/inspec
synced 2024-11-27 07:00:39 +00:00
Merge pull request #1201 from chef/dr/empty-filter
bugfix: support nil entries in filter table
This commit is contained in:
commit
78b02c754d
2 changed files with 11 additions and 0 deletions
|
@ -44,6 +44,7 @@ module FilterTable
|
|||
def initialize(resource, params, filters)
|
||||
@resource = resource
|
||||
@params = params
|
||||
@params = [] if @params.nil?
|
||||
@filters = filters
|
||||
end
|
||||
|
||||
|
|
|
@ -28,6 +28,16 @@ describe FilterTable do
|
|||
factory.must_be_kind_of FilterTable::Factory
|
||||
end
|
||||
|
||||
it 'supports empty arrays' do
|
||||
factory.add_accessor(:where).add(:baz).connect(resource, :data)
|
||||
resource.new([]).where { false }.params.must_equal []
|
||||
end
|
||||
|
||||
it 'supports nil arrays' do
|
||||
factory.add_accessor(:where).add(:baz).connect(resource, :data)
|
||||
resource.new(nil).where { false }.params.must_equal []
|
||||
end
|
||||
|
||||
it 'retrieves the resource from all entries' do
|
||||
factory.add_accessor(:where)
|
||||
.add(:baz?) { |x| x.resource }
|
||||
|
|
Loading…
Reference in a new issue