You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

21 lines
594 B

  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. describe FastIpMap do
  4. describe '#include?' do
  5. subject { described_class.new([IPAddr.new('20.4.0.0/16'), IPAddr.new('145.22.30.0/24'), IPAddr.new('189.45.86.3')])}
  6. it 'returns true for an exact match' do
  7. expect(subject.include?(IPAddr.new('189.45.86.3'))).to be true
  8. end
  9. it 'returns true for a range match' do
  10. expect(subject.include?(IPAddr.new('20.4.45.7'))).to be true
  11. end
  12. it 'returns false for no match' do
  13. expect(subject.include?(IPAddr.new('145.22.40.64'))).to be false
  14. end
  15. end
  16. end