make portspec specs not insane

the specs for the portspec_to_portlist method
need a lot of work. this gives us some btter minimum coverage
bug/bundler_fix
David Maloney 2014-06-25 14:10:06 -05:00
parent 97d08a081a
commit 42bfe8ba4f
No known key found for this signature in database
GPG Key ID: DEDBA9DC3A913DB2
1 changed files with 20 additions and 19 deletions

View File

@ -1,5 +1,6 @@
# -*- coding:binary -*-
require 'rex/socket/range_walker'
require 'spec_helper'
describe Rex::Socket do
@ -166,30 +167,30 @@ describe Rex::Socket do
describe '.portspec_to_portlist' do
portspec = '-1,0-10,!2-5,!7,65530-,65536'
context "'#{portspec}'" do
subject(:portlist) { described_class.portspec_to_portlist portspec_string}
let(:portspec_string) { '-1,0-10,!2-5,!7,65530-,65536' }
subject { described_class.portspec_to_portlist portspec }
it { should be_a(Array) }
not_included = []
not_included << -1
not_included << 65536
not_included.concat (2..5).to_a
not_included << 7
not_included.each do |item|
it { should_not include item }
it 'does not include negative numbers' do
expect(portlist).to_not include '-1'
end
included = []
included << -1
included.concat (0..10).to_a
included.concat (65530..65535).to_a
included << 65536
included = included - not_included
included.each do |item|
it { should include item }
it 'does not include 0' do
expect(portlist).to_not include '0'
end
it 'does not include negated numbers' do
['2', '3', '4', '5', '7'].each do |port|
expect(portlist).to_not include port
end
end
it 'does not include any numbers above 65535' do
expect(portlist).to_not include '65536'
end
it 'expands open ended ranges' do
(65530..65535).each do |port|
expect(portlist).to include port
end
end
end