~cytrogen/masto-fe

ref: 0cb343eec2086809564455319b4bc3f1343c5dd4 masto-fe/spec/lib/fast_ip_map_spec.rb -rw-r--r-- 595 bytes
0cb343ee — Claire Tag nightly images as `latest` in glitch-soc, as it has no proper releases (#2414) 2 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# frozen_string_literal: true

require 'rails_helper'

describe FastIpMap do
  describe '#include?' do
    subject { described_class.new([IPAddr.new('20.4.0.0/16'), IPAddr.new('145.22.30.0/24'), IPAddr.new('189.45.86.3')]) }

    it 'returns true for an exact match' do
      expect(subject.include?(IPAddr.new('189.45.86.3'))).to be true
    end

    it 'returns true for a range match' do
      expect(subject.include?(IPAddr.new('20.4.45.7'))).to be true
    end

    it 'returns false for no match' do
      expect(subject.include?(IPAddr.new('145.22.40.64'))).to be false
    end
  end
end