Created
February 16, 2017 13:41
-
-
Save kalabiyau/4b70ba501b61d814b90a85ffbfe7280d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'ipaddr' | |
require 'test/unit' | |
class TC_MyTest < Test::Unit::TestCase | |
REGEX_UNDER_QUESTION = %r{172\.([1][6-9]|[2][0-9]|[3][0-1])\.\d+\.\d+} | |
def setup | |
start = IPAddr.new('172.16.0.0') | |
finish = IPAddr.new('172.31.255.255') | |
@ip_range = (start..finish).map(&:to_s) | |
end | |
def test_green | |
assert_block 'Range is not covered' do | |
@ip_range.select{|x| !x[REGEX_UNDER_QUESTION]}.empty? | |
end | |
end | |
def test_red | |
assert_block 'Poke teh range!' do | |
@ip_range += %w{ 172.12.1.2 172.32.1.1 168.12.21.1 } | |
@ip_range.select{|x| !x[REGEX_UNDER_QUESTION]}.size.eql?(3) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment