CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
rapid7

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: rapid7/metasploit-framework
Path: blob/master/spec/lib/msf/ui/console/command_dispatcher_spec.rb
Views: 11766
1
require 'rspec'
2
3
RSpec.describe Msf::Ui::Console::CommandDispatcher do
4
include_context 'Msf::DBManager'
5
include_context 'Msf::UIDriver'
6
7
let(:subject) do
8
dummy_class = Class.new
9
dummy_class.include described_class
10
dummy_class.new(driver)
11
end
12
13
describe '#build_range_array' do
14
[
15
{ input: '1', expected: [1] },
16
{ input: '123', expected: [123] },
17
{ input: '-1', expected: [-1] },
18
{ input: '-123', expected: [-123] },
19
{ input: '1,2', expected: [1, 2] },
20
{ input: '-1,2', expected: [-1, 2] },
21
{ input: '2,-1', expected: [-1, 2] },
22
{ input: '-1,-2', expected: [-2, -1] },
23
{ input: '-1-', expected: nil },
24
{ input: '-1-,2', expected: nil },
25
{ input: '-1--,2', expected: nil },
26
{ input: '---1', expected: nil },
27
{ input: '1--', expected: nil },
28
{ input: '1-3', expected: [1, 2, 3] },
29
{ input: '-1-3', expected: nil },
30
{ input: '-1--4', expected: nil },
31
{ input: '1..4', expected: [1, 2, 3, 4] },
32
{ input: '1..-4', expected: nil },
33
{ input: '-1..4', expected: nil },
34
{ input: '-1..-4', expected: nil },
35
{ input: '-1,0-3', expected: [-1, 0, 1, 2, 3] },
36
{ input: '-1,0,1,2', expected: [-1, 0, 1, 2] },
37
{ input: '-1,-1', expected: [-1] },
38
{ input: '-1,1..2', expected: [-1, 1, 2] }
39
].each do |test|
40
it "returns #{test[:expected].inspect} for the input #{test[:input]}" do
41
expect(subject.build_range_array(test[:input])).to eq(test[:expected])
42
end
43
end
44
end
45
end
46
47