mirror of
https://github.com/inspec/inspec
synced 2024-11-26 22:50:36 +00:00
Merge pull request #5598 from inspec/nm/filtertable-range
Fix range based filtering in filter tables
This commit is contained in:
commit
d191964e23
2 changed files with 18 additions and 1 deletions
|
@ -256,7 +256,7 @@ module FilterTable
|
|||
end
|
||||
|
||||
def matches(x, y)
|
||||
x === y # rubocop:disable Style/CaseEquality
|
||||
y === x # rubocop:disable Style/CaseEquality
|
||||
end
|
||||
|
||||
def filter_raw_data(current_raw_data, field, desired_value)
|
||||
|
|
|
@ -35,6 +35,11 @@ describe FilterTable do
|
|||
_(resource.new(nil).where { false }.params).must_equal []
|
||||
end
|
||||
|
||||
it "supports range" do
|
||||
factory.add_accessor(:where).connect(resource, :data)
|
||||
_(instance.where({ foo: (3..5) }).params).must_equal [data[0]]
|
||||
end
|
||||
|
||||
it "retrieves the resource from all entries" do
|
||||
factory.add_accessor(:where)
|
||||
.add(:baz?) { |x| x.resource } # rubocop: disable Style/SymbolProc
|
||||
|
@ -181,4 +186,16 @@ describe FilterTable do
|
|||
_(instance.baz(/zzz/).params).must_equal []
|
||||
end
|
||||
end
|
||||
|
||||
describe "with a range filter" do
|
||||
before { factory.add(:foo).connect(resource, :data) }
|
||||
|
||||
it "filter and retrieves data with matching range" do
|
||||
_(instance.foo((3..5)).params).must_equal [data[0]]
|
||||
end
|
||||
|
||||
it "filter and retrieves empty result if no data in matching range" do
|
||||
_(instance.foo((4..5)).params).must_equal []
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue