ruby-nmap 0.7.0 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ChangeLog.md +17 -0
- data/Gemfile +7 -5
- data/lib/nmap/address.rb +1 -1
- data/lib/nmap/host.rb +27 -2
- data/lib/nmap/hostname.rb +22 -0
- data/lib/nmap/os.rb +1 -1
- data/lib/nmap/program.rb +23 -0
- data/lib/nmap/task.rb +9 -9
- data/lib/nmap/version.rb +1 -1
- data/lib/nmap/xml.rb +80 -1
- data/ruby-nmap.gemspec +1 -1
- data/spec/address_spec.rb +1 -1
- data/spec/cpe/url_spec.rb +16 -16
- data/spec/cpe_examples.rb +2 -2
- data/spec/hop_spec.rb +1 -1
- data/spec/host_spec.rb +69 -44
- data/spec/hostname_spec.rb +20 -3
- data/spec/ip_id_sequence_spec.rb +2 -2
- data/spec/nmap_spec.rb +1 -1
- data/spec/os_class_spec.rb +20 -10
- data/spec/os_match_spec.rb +1 -1
- data/spec/os_spec.rb +10 -9
- data/spec/port_spec.rb +18 -10
- data/spec/run_stat_spec.rb +1 -1
- data/spec/scan.xml +1 -0
- data/spec/scan_spec.rb +4 -4
- data/spec/scan_task_spec.rb +3 -3
- data/spec/scanner_spec.rb +1 -1
- data/spec/scripts_examples.rb +2 -2
- data/spec/sequence_examples.rb +4 -2
- data/spec/service_spec.rb +11 -11
- data/spec/spec_helper.rb +0 -26
- data/spec/status_spec.rb +1 -1
- data/spec/task_spec.rb +6 -6
- data/spec/tcp_sequence_spec.rb +3 -3
- data/spec/tcp_ts_sequence_spec.rb +2 -2
- data/spec/traceroute_spec.rb +20 -9
- data/spec/uptime_spec.rb +1 -1
- data/spec/xml_spec.rb +82 -44
- metadata +3 -3
data/spec/run_stat_spec.rb
CHANGED
@@ -15,7 +15,7 @@ describe RunStat do
|
|
15
15
|
subject { described_class.new(end_time,elapsed,summary,exit_status) }
|
16
16
|
|
17
17
|
it "should convert the RunStat to a String" do
|
18
|
-
subject.to_s.
|
18
|
+
expect(subject.to_s).to eq("#{end_time} #{elapsed} #{exit_status}")
|
19
19
|
end
|
20
20
|
end
|
21
21
|
end
|
data/spec/scan.xml
CHANGED
@@ -44,6 +44,7 @@
|
|
44
44
|
<taskend task="NSE" time="1374390873"/>
|
45
45
|
<host starttime="1374389727" endtime="1374390873"><status state="up" reason="reset"/>
|
46
46
|
<address addr="74.207.244.221" addrtype="ipv4"/>
|
47
|
+
<address addr="08:00:27:7F:62:DC" addrtype="mac" vendor="Cadmus Computer Systems"/ >
|
47
48
|
<hostnames>
|
48
49
|
<hostname name="scanme.nmap.org" type="user"/>
|
49
50
|
<hostname name="scanme.nmap.org" type="PTR"/>
|
data/spec/scan_spec.rb
CHANGED
@@ -9,12 +9,12 @@ describe Scan do
|
|
9
9
|
subject { described_class.new(type,protocol) }
|
10
10
|
|
11
11
|
it "should accept a type and protocol" do
|
12
|
-
subject.type.
|
13
|
-
subject.protocol.
|
12
|
+
expect(subject.type).to eq(type)
|
13
|
+
expect(subject.protocol).to eq(protocol)
|
14
14
|
end
|
15
15
|
|
16
16
|
it "should default services to []" do
|
17
|
-
subject.services.
|
17
|
+
expect(subject.services).to eq([])
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
@@ -22,7 +22,7 @@ describe Scan do
|
|
22
22
|
subject { described_class.new(type,protocol) }
|
23
23
|
|
24
24
|
it "should include the type and protocol" do
|
25
|
-
subject.to_s.
|
25
|
+
expect(subject.to_s).to eq("#{protocol} #{type}")
|
26
26
|
end
|
27
27
|
end
|
28
28
|
end
|
data/spec/scan_task_spec.rb
CHANGED
@@ -19,17 +19,17 @@ describe ScanTask do
|
|
19
19
|
|
20
20
|
describe "#duration" do
|
21
21
|
it "should be > 0" do
|
22
|
-
subject.duration.
|
22
|
+
expect(subject.duration).to be > 0
|
23
23
|
end
|
24
24
|
|
25
25
|
it "should be the time between the start_time and end_time" do
|
26
|
-
(subject.start_time + subject.duration).
|
26
|
+
expect(subject.start_time + subject.duration).to eq(subject.end_time)
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
30
|
describe "#to_s" do
|
31
31
|
it "should include the start_time, name and extrainfo" do
|
32
|
-
subject.to_s.
|
32
|
+
expect(subject.to_s).to eq("#{start_time}: #{name} (#{extrainfo})")
|
33
33
|
end
|
34
34
|
end
|
35
35
|
end
|
data/spec/scanner_spec.rb
CHANGED
data/spec/scripts_examples.rb
CHANGED
data/spec/sequence_examples.rb
CHANGED
@@ -4,7 +4,9 @@ shared_examples_for "Sequence" do
|
|
4
4
|
describe "#values" do
|
5
5
|
subject { super().values }
|
6
6
|
|
7
|
-
it
|
8
|
-
|
7
|
+
it 'has 6 items' do
|
8
|
+
expect(subject.size).to eq(6)
|
9
|
+
end
|
10
|
+
it { is_expected.to all(be_between(0,0xFFFFFFFF)) }
|
9
11
|
end
|
10
12
|
end
|
data/spec/service_spec.rb
CHANGED
@@ -9,67 +9,67 @@ describe Service do
|
|
9
9
|
|
10
10
|
describe "#name" do
|
11
11
|
it "should parse the name" do
|
12
|
-
subject.name.
|
12
|
+
expect(subject.name).to eq('ssh')
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
16
|
describe "#ssl?" do
|
17
17
|
it "should check the tunnel attribute" do
|
18
|
-
|
18
|
+
skip "need a service that uses SSL"
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
22
|
describe "#protocol" do
|
23
23
|
it "should parse the proto attribute" do
|
24
|
-
|
24
|
+
skip "need a service with the proto attribute"
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
28
|
describe "#product" do
|
29
29
|
it "should parse the product name attribute" do
|
30
|
-
subject.product.
|
30
|
+
expect(subject.product).to eq('OpenSSH')
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
34
|
describe "#version" do
|
35
35
|
it "should parse the version attribute" do
|
36
|
-
subject.version.
|
36
|
+
expect(subject.version).to eq('5.3p1 Debian 3ubuntu7')
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
40
40
|
describe "#extra_info" do
|
41
41
|
it "should parse the extrainfo attribute" do
|
42
|
-
subject.extra_info.
|
42
|
+
expect(subject.extra_info).to eq('protocol 2.0')
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
46
46
|
describe "#hostname" do
|
47
47
|
it "should parse the hostname attribute" do
|
48
|
-
|
48
|
+
skip "need a service with the hostname attribute"
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
52
52
|
describe "#os_type" do
|
53
53
|
it "should parse the ostype attribute" do
|
54
|
-
subject.os_type.
|
54
|
+
expect(subject.os_type).to eq('Linux')
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
58
58
|
describe "#device_type" do
|
59
59
|
it "should parse the devicetype attribute" do
|
60
|
-
|
60
|
+
skip "need a service with the devicetype attribute"
|
61
61
|
end
|
62
62
|
end
|
63
63
|
|
64
64
|
describe "#fingerprint_method" do
|
65
65
|
it "should parse the method attribute" do
|
66
|
-
subject.fingerprint_method.
|
66
|
+
expect(subject.fingerprint_method).to eq(:probed)
|
67
67
|
end
|
68
68
|
end
|
69
69
|
|
70
70
|
describe "#confidence" do
|
71
71
|
it "should parse the conf attribute" do
|
72
|
-
subject.confidence.
|
72
|
+
expect(subject.confidence).to be_between(0,10)
|
73
73
|
end
|
74
74
|
end
|
75
75
|
|
data/spec/spec_helper.rb
CHANGED
@@ -6,32 +6,6 @@ require 'nmap/version'
|
|
6
6
|
require 'nmap/xml'
|
7
7
|
include Nmap
|
8
8
|
|
9
|
-
RSpec::Matchers.define :be_between do |min,max|
|
10
|
-
match do |value|
|
11
|
-
(value >= min) && (value <= max)
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
RSpec::Matchers.define :all_be_between do |min,max|
|
16
|
-
match do |values|
|
17
|
-
values.all? { |value| (value >= min) && (value <= max) }
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
RSpec::Matchers.define :be_one_of do |*values|
|
22
|
-
match do |value|
|
23
|
-
values.include?(value)
|
24
|
-
end
|
25
|
-
|
26
|
-
description { "be one of: #{expected.join(', ')}" }
|
27
|
-
end
|
28
|
-
|
29
|
-
RSpec::Matchers.define :all_be_kind_of do |base_class|
|
30
|
-
match do |values|
|
31
|
-
values.all? { |value| value.kind_of?(base_class) }
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
9
|
RSpec.configure do |spec|
|
36
10
|
spec.before(:all) do
|
37
11
|
@xml = XML.new('spec/scan.xml')
|
data/spec/status_spec.rb
CHANGED
data/spec/task_spec.rb
CHANGED
@@ -2,35 +2,35 @@ require 'spec_helper'
|
|
2
2
|
require 'nmap/task'
|
3
3
|
|
4
4
|
describe Task do
|
5
|
-
describe "ports" do
|
5
|
+
describe "#ports=" do
|
6
6
|
it "should ignore empty port Arrays" do
|
7
7
|
subject.ports = []
|
8
8
|
|
9
|
-
subject.arguments.
|
9
|
+
expect(subject.arguments).to eq([])
|
10
10
|
end
|
11
11
|
|
12
12
|
it "should format a String of ports" do
|
13
13
|
subject.ports = '80,21,25'
|
14
14
|
|
15
|
-
subject.arguments.
|
15
|
+
expect(subject.arguments).to eq(%w[-p 80,21,25])
|
16
16
|
end
|
17
17
|
|
18
18
|
it "should format an Array of String ports" do
|
19
19
|
subject.ports = %w[80 21 25]
|
20
20
|
|
21
|
-
subject.arguments.
|
21
|
+
expect(subject.arguments).to eq(%w[-p 80,21,25])
|
22
22
|
end
|
23
23
|
|
24
24
|
it "should format an Array of Integer ports" do
|
25
25
|
subject.ports = [80, 21, 25]
|
26
26
|
|
27
|
-
subject.arguments.
|
27
|
+
expect(subject.arguments).to eq(%w[-p 80,21,25])
|
28
28
|
end
|
29
29
|
|
30
30
|
it "should format a Range of ports" do
|
31
31
|
subject.ports = [80, 21..25]
|
32
32
|
|
33
|
-
subject.arguments.
|
33
|
+
expect(subject.arguments).to eq(%w[-p 80,21-25])
|
34
34
|
end
|
35
35
|
end
|
36
36
|
end
|
data/spec/tcp_sequence_spec.rb
CHANGED
@@ -8,13 +8,13 @@ describe TcpSequence do
|
|
8
8
|
|
9
9
|
describe "#index" do
|
10
10
|
it "should parse the index" do
|
11
|
-
subject.index.
|
11
|
+
expect(subject.index).to be > 0
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
15
|
describe "#description" do
|
16
16
|
it "should parse the difficulty description" do
|
17
|
-
subject.difficulty.
|
17
|
+
expect(subject.difficulty).to eq("Good luck!")
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
@@ -36,7 +36,7 @@ describe TcpSequence do
|
|
36
36
|
end
|
37
37
|
|
38
38
|
it "should contain the description and values" do
|
39
|
-
subject.to_s.
|
39
|
+
expect(subject.to_s).to match(regexp)
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
@@ -8,7 +8,7 @@ describe TcpTsSequence do
|
|
8
8
|
|
9
9
|
describe "#description" do
|
10
10
|
it "should parse the description" do
|
11
|
-
subject.description.
|
11
|
+
expect(subject.description).to eq("1000HZ")
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
@@ -26,7 +26,7 @@ describe TcpTsSequence do
|
|
26
26
|
end
|
27
27
|
|
28
28
|
it "should contain the description and values" do
|
29
|
-
subject.to_s.
|
29
|
+
expect(subject.to_s).to match(regexp)
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
data/spec/traceroute_spec.rb
CHANGED
@@ -7,25 +7,36 @@ describe Traceroute do
|
|
7
7
|
describe "#port" do
|
8
8
|
subject { super().port }
|
9
9
|
|
10
|
-
it {
|
11
|
-
it {
|
12
|
-
it {
|
10
|
+
it { is_expected.to be_kind_of(Integer) }
|
11
|
+
it { is_expected.to be > 0 }
|
12
|
+
it { is_expected.to be < 65535 }
|
13
13
|
end
|
14
14
|
|
15
15
|
describe "#protocol" do
|
16
16
|
subject { super().protocol }
|
17
17
|
|
18
|
-
it {
|
19
|
-
it {
|
18
|
+
it { is_expected.to be_kind_of(Symbol) }
|
19
|
+
it { is_expected.to eq(:tcp).or eq(:udp) }
|
20
20
|
end
|
21
21
|
|
22
22
|
describe "#each" do
|
23
23
|
subject { super().each.first }
|
24
24
|
|
25
|
-
it {
|
25
|
+
it { is_expected.to be_kind_of(Hop) }
|
26
26
|
|
27
|
-
|
28
|
-
|
29
|
-
|
27
|
+
describe '#addr' do
|
28
|
+
subject { super().addr }
|
29
|
+
it { is_expected.to be_kind_of(String) }
|
30
|
+
end
|
31
|
+
|
32
|
+
describe '#ttl' do
|
33
|
+
subject { super().ttl }
|
34
|
+
it { is_expected.to be_kind_of(String) }
|
35
|
+
end
|
36
|
+
|
37
|
+
describe '#rtt' do
|
38
|
+
subject { super().rtt }
|
39
|
+
it { is_expected.to be_kind_of(String) }
|
40
|
+
end
|
30
41
|
end
|
31
42
|
end
|
data/spec/uptime_spec.rb
CHANGED
@@ -9,7 +9,7 @@ describe Uptime do
|
|
9
9
|
subject { described_class.new(seconds,last_boot) }
|
10
10
|
|
11
11
|
it "should convert the uptipe to a String" do
|
12
|
-
subject.to_s.
|
12
|
+
expect(subject.to_s).to eq("uptime: #{seconds} (#{last_boot})")
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
data/spec/xml_spec.rb
CHANGED
@@ -11,7 +11,7 @@ describe XML do
|
|
11
11
|
let(:document) { Nokogiri::XML(File.read(path)) }
|
12
12
|
|
13
13
|
it "should use the document" do
|
14
|
-
described_class.new(document).version.
|
14
|
+
expect(described_class.new(document).version).to eq(subject.version)
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
@@ -19,36 +19,46 @@ describe XML do
|
|
19
19
|
let(:io) { File.new(path) }
|
20
20
|
|
21
21
|
it "should parse the IO object" do
|
22
|
-
described_class.new(io).version.
|
22
|
+
expect(described_class.new(io).version).to eq(subject.version)
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
26
|
context "when given a String" do
|
27
27
|
it "should parse the file at the path" do
|
28
|
-
described_class.new(path).version.
|
28
|
+
expect(described_class.new(path).version).to eq(subject.version)
|
29
29
|
end
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
|
-
describe "
|
34
|
-
|
35
|
-
|
33
|
+
describe "parse" do
|
34
|
+
let(:xml) { File.read(path) }
|
35
|
+
|
36
|
+
subject { described_class.parse(xml) }
|
37
|
+
|
38
|
+
it "should return an XML object" do
|
39
|
+
expect(subject).to be_kind_of(described_class)
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should parse the XML" do
|
43
|
+
expect(subject.version).to_not be_nil
|
36
44
|
end
|
37
45
|
end
|
38
46
|
|
39
47
|
describe "open" do
|
40
|
-
|
41
|
-
|
48
|
+
subject { described_class.open(path) }
|
49
|
+
|
50
|
+
it "should return an XML object" do
|
51
|
+
expect(subject).to be_kind_of(described_class)
|
42
52
|
end
|
43
53
|
|
44
|
-
it "should
|
45
|
-
subject.
|
54
|
+
it "should parse the XML" do
|
55
|
+
expect(subject.version).to_not be_nil
|
46
56
|
end
|
47
57
|
end
|
48
58
|
|
49
59
|
describe "#version" do
|
50
60
|
it "should have a version" do
|
51
|
-
subject.version.
|
61
|
+
expect(subject.version).to eq('1.04')
|
52
62
|
end
|
53
63
|
end
|
54
64
|
|
@@ -58,15 +68,15 @@ describe XML do
|
|
58
68
|
end
|
59
69
|
|
60
70
|
it "should parse the scanner name" do
|
61
|
-
subject.scanner.name.
|
71
|
+
expect(subject.scanner.name).to eq('nmap')
|
62
72
|
end
|
63
73
|
|
64
74
|
it "should parse the scanner arguments" do
|
65
|
-
subject.scanner.arguments.
|
75
|
+
expect(subject.scanner.arguments).to eq('nmap -v -sS -sU -A -O -oX spec/scan.xml scanme.nmap.org')
|
66
76
|
end
|
67
77
|
|
68
78
|
it "should parse the scanner start time" do
|
69
|
-
subject.scanner.start_time.
|
79
|
+
expect(subject.scanner.start_time).to be_kind_of(Time)
|
70
80
|
end
|
71
81
|
end
|
72
82
|
|
@@ -74,138 +84,166 @@ describe XML do
|
|
74
84
|
subject { super().scan_info.first }
|
75
85
|
|
76
86
|
it "should parse the type" do
|
77
|
-
subject.type.
|
87
|
+
expect(subject.type).to eq(:syn)
|
78
88
|
end
|
79
89
|
|
80
90
|
it "should parse the protocol" do
|
81
|
-
subject.protocol.
|
91
|
+
expect(subject.protocol).to eq(:tcp)
|
82
92
|
end
|
83
93
|
|
84
94
|
it "should parse the services" do
|
85
|
-
subject.services.
|
95
|
+
expect(subject.services).not_to be_empty
|
86
96
|
end
|
87
97
|
end
|
88
98
|
|
89
99
|
it "should parse the verbose level" do
|
90
|
-
subject.verbose.
|
100
|
+
expect(subject.verbose).to eq(1)
|
91
101
|
end
|
92
102
|
|
93
103
|
it "should parse the debugging level" do
|
94
|
-
subject.debugging.
|
104
|
+
expect(subject.debugging).to eq(0)
|
95
105
|
end
|
96
106
|
|
97
107
|
describe "#each_run_stat" do
|
98
108
|
subject { super().each_run_stat.first }
|
99
109
|
|
100
110
|
it "should yield RunStat objects" do
|
101
|
-
subject.
|
111
|
+
expect(subject).to be_kind_of(RunStat)
|
102
112
|
end
|
103
113
|
|
104
114
|
it "should parse the end time" do
|
105
|
-
subject.end_time.
|
115
|
+
expect(subject.end_time).to be_kind_of(Time)
|
106
116
|
end
|
107
117
|
|
108
118
|
it "should parse the time elapsed" do
|
109
|
-
subject.elapsed.
|
119
|
+
expect(subject.elapsed).not_to be_nil
|
110
120
|
end
|
111
121
|
|
112
122
|
it "should parse the summary" do
|
113
|
-
subject.summary.
|
123
|
+
expect(subject.summary).not_to be_empty
|
114
124
|
end
|
115
125
|
|
116
126
|
it "should parse the exit status" do
|
117
|
-
subject.exit_status.
|
127
|
+
expect(subject.exit_status).to eq('success').or eq('failure')
|
118
128
|
end
|
119
129
|
end
|
120
130
|
|
121
131
|
describe "#run_stats" do
|
122
132
|
subject { super().run_stats }
|
123
133
|
|
124
|
-
it {
|
125
|
-
it {
|
134
|
+
it { is_expected.not_to be_empty }
|
135
|
+
it { is_expected.to all(be_kind_of(RunStat)) }
|
126
136
|
end
|
127
137
|
|
128
138
|
describe "#each_task" do
|
129
139
|
subject { super().each_task.first }
|
130
140
|
|
131
141
|
it "should parse task name" do
|
132
|
-
subject.name.
|
142
|
+
expect(subject.name).to eq('Ping Scan')
|
133
143
|
end
|
134
144
|
|
135
145
|
it "should parse the start time" do
|
136
|
-
subject.start_time.
|
146
|
+
expect(subject.start_time).to be_kind_of(Time)
|
137
147
|
end
|
138
148
|
|
139
149
|
it "should parse the end time" do
|
140
|
-
subject.end_time.
|
141
|
-
subject.end_time.
|
150
|
+
expect(subject.end_time).to be_kind_of(Time)
|
151
|
+
expect(subject.end_time).to be > subject.start_time
|
142
152
|
end
|
143
153
|
|
144
154
|
it "should parse the extrainfo" do
|
145
|
-
subject.extrainfo.
|
155
|
+
expect(subject.extrainfo).not_to be_empty
|
146
156
|
end
|
147
157
|
end
|
148
158
|
|
149
159
|
describe "#tasks" do
|
150
160
|
subject { super().tasks }
|
151
161
|
|
152
|
-
it {
|
153
|
-
it {
|
162
|
+
it { is_expected.not_to be_empty }
|
163
|
+
it { is_expected.to all(be_kind_of(ScanTask)) }
|
154
164
|
end
|
155
165
|
|
156
166
|
describe "#each_host" do
|
157
167
|
subject { super().each_host.first }
|
158
168
|
|
159
169
|
it "should yield Host objects" do
|
160
|
-
subject.
|
170
|
+
expect(subject).to be_kind_of(Host)
|
161
171
|
end
|
162
172
|
end
|
163
173
|
|
164
174
|
describe "#hosts" do
|
165
175
|
subject { super().hosts }
|
166
176
|
|
167
|
-
it {
|
168
|
-
it { subject.
|
177
|
+
it { is_expected.not_to be_empty }
|
178
|
+
it { expect(subject).to all(be_kind_of(Host)) }
|
179
|
+
end
|
180
|
+
|
181
|
+
describe "#host" do
|
182
|
+
subject { super().host }
|
183
|
+
|
184
|
+
it { expect(subject).to be_kind_of(Host) }
|
185
|
+
end
|
186
|
+
|
187
|
+
describe "#down_host" do
|
188
|
+
pending "need down hosts in scan.xml" do
|
189
|
+
subject { super().down_host }
|
190
|
+
|
191
|
+
it { is_expected.to be_kind_of(Host) }
|
192
|
+
|
193
|
+
it "should contain only up hosts" do
|
194
|
+
expect(subject.status.state).to be(:down)
|
195
|
+
end
|
196
|
+
end
|
169
197
|
end
|
170
198
|
|
171
199
|
describe "#each_up_host" do
|
172
200
|
subject { super().each_up_host.first }
|
173
201
|
|
174
202
|
it "should yield Host objects" do
|
175
|
-
subject.
|
203
|
+
expect(subject).to be_kind_of(Host)
|
176
204
|
end
|
177
205
|
|
178
206
|
it "should be up" do
|
179
|
-
subject.status.state.
|
207
|
+
expect(subject.status.state).to eq(:up)
|
180
208
|
end
|
181
209
|
end
|
182
210
|
|
183
211
|
describe "#up_hosts" do
|
184
212
|
subject { super().up_hosts }
|
185
213
|
|
186
|
-
it {
|
187
|
-
it {
|
214
|
+
it { is_expected.not_to be_empty }
|
215
|
+
it { is_expected.to all(be_kind_of(Host)) }
|
216
|
+
|
217
|
+
it "should contain only up hosts" do
|
218
|
+
expect(subject.all? { |host| host.status.state == :up }).to be_truthy
|
219
|
+
end
|
220
|
+
end
|
221
|
+
|
222
|
+
describe "#up_host" do
|
223
|
+
subject { super().up_host }
|
224
|
+
|
225
|
+
it { is_expected.to be_kind_of(Host) }
|
188
226
|
|
189
227
|
it "should contain only up hosts" do
|
190
|
-
subject.
|
228
|
+
expect(subject.status.state).to be(:up)
|
191
229
|
end
|
192
230
|
end
|
193
231
|
|
194
232
|
describe "#each" do
|
195
233
|
it "should iterate over each up host" do
|
196
|
-
subject.each.all? { |host| host.status.state == :up }.
|
234
|
+
expect(subject.each.all? { |host| host.status.state == :up }).to eq(true)
|
197
235
|
end
|
198
236
|
end
|
199
237
|
|
200
238
|
describe "#to_s" do
|
201
239
|
it "should convert to a String" do
|
202
|
-
subject.to_s.
|
240
|
+
expect(subject.to_s).to eq(path)
|
203
241
|
end
|
204
242
|
end
|
205
243
|
|
206
244
|
describe "#inspect" do
|
207
245
|
it "should include the class and path" do
|
208
|
-
subject.inspect.
|
246
|
+
expect(subject.inspect).to eq("#<#{described_class}: #{path}>")
|
209
247
|
end
|
210
248
|
end
|
211
249
|
end
|