spec/service_spec.rb in ruby-nmap-0.8.0 vs spec/service_spec.rb in ruby-nmap-0.9.0
- old
+ new
@@ -3,15 +3,17 @@
require 'nmap/xml'
require 'nmap/service'
describe Service do
- subject { @xml.hosts.first.ports.first.service }
+ let(:port) { @xml.host.open_ports.find { |port| port.number == 80 } }
+ subject { port.service }
+
describe "#name" do
it "should parse the name" do
- expect(subject.name).to eq('ssh')
+ expect(subject.name).to eq('http')
end
end
describe "#ssl?" do
it "should check the tunnel attribute" do
@@ -25,23 +27,23 @@
end
end
describe "#product" do
it "should parse the product name attribute" do
- expect(subject.product).to eq('OpenSSH')
+ expect(subject.product).to eq('Apache httpd')
end
end
describe "#version" do
it "should parse the version attribute" do
- expect(subject.version).to eq('5.3p1 Debian 3ubuntu7')
+ expect(subject.version).to eq('2.4.7')
end
end
describe "#extra_info" do
it "should parse the extrainfo attribute" do
- expect(subject.extra_info).to eq('protocol 2.0')
+ expect(subject.extra_info).to eq('(Ubuntu)')
end
end
describe "#hostname" do
it "should parse the hostname attribute" do
@@ -49,11 +51,11 @@
end
end
describe "#os_type" do
it "should parse the ostype attribute" do
- expect(subject.os_type).to eq('Linux')
+ skip "need a service with the ostype attribute"
end
end
describe "#device_type" do
it "should parse the devicetype attribute" do
@@ -68,9 +70,17 @@
end
describe "#confidence" do
it "should parse the conf attribute" do
expect(subject.confidence).to be_between(0,10)
+ end
+ end
+
+ describe "#to_s" do
+ context "when #product and #version are not nil" do
+ it "should include the product and version" do
+ expect(subject.to_s).to be == "#{subject.product} #{subject.version}"
+ end
end
end
it_should_behave_like "CPE"
end