1
0

fast_ip_map_spec.rb 601 B

123456789101112131415161718192021
  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. RSpec.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