diff --git a/spec/lib/rex/socket_spec.rb b/spec/lib/rex/socket_spec.rb index 3bc99de1bc..fdf1610129 100644 --- a/spec/lib/rex/socket_spec.rb +++ b/spec/lib/rex/socket_spec.rb @@ -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 'does not include negative numbers' do + expect(portlist).to_not include '-1' + end - it { should be_a(Array) } + it 'does not include 0' do + expect(portlist).to_not include '0' + end - 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 negated numbers' do + ['2', '3', '4', '5', '7'].each do |port| + expect(portlist).to_not include port end + 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 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