diff --git a/spec/public/versions_spec.rb b/spec/public/versions_spec.rb index a8297ab..330d1bd 100644 --- a/spec/public/versions_spec.rb +++ b/spec/public/versions_spec.rb @@ -78,4 +78,31 @@ end end end + + describe '#in_range' do + let(:versions) do + [ + ResourceRegistry::Versions::Version.new('2024-01-01'), + ResourceRegistry::Versions::Version.new('2024-04-28'), + ResourceRegistry::Versions::Version.new('2024-09-20'), + ResourceRegistry::Versions::Version.new('2025-01-09') + ] + end + + it 'filtered the version by >= from & <= to' do + expect(subject.in_range('2024-04-28', '2024-09-20')).count.to eq(2) + end + + context 'without to' do + it 'filtered the version by >= from' do + expect(subject.in_range('2024-04-28', nil)).count.to eq(3) + end + end + + context 'without from' do + it 'filtered the version by <= to' do + expect(subject.in_range(nil, '2024-09-20')).count.to eq(3) + end + end + end end