spec/port_spec.rb in ruby-nmap-0.5.1 vs spec/port_spec.rb in ruby-nmap-0.6.0
- old
+ new
@@ -1,44 +1,39 @@
require 'spec_helper'
-require 'helpers/xml'
-
-require 'nmap/xml'
require 'nmap/port'
describe Port do
- include Helpers
+ let(:xml) { XML.new(Helpers::SCAN_FILE) }
- before(:all) do
- @xml = XML.new(Helpers::SCAN_FILE)
- @nse_xml = XML.new(Helpers::NSE_FILE)
+ subject { xml.hosts.first.ports.first }
- @port = @xml.hosts.first.ports.first
- @nse_port = @nse_xml.hosts.first.ports.first
- end
-
it "should parse the protocol" do
- @port.protocol.should == :tcp
+ subject.protocol.should == :tcp
end
it "should parse the port number" do
- @port.number.should == 21
+ subject.number.should == 21
end
it "should parse the state" do
- @port.state.should == :closed
+ subject.state.should == :closed
end
it "should parse the reason" do
- @port.reason.should == 'reset'
+ subject.reason.should == 'reset'
end
it "should parse the detected service" do
- @port.service.should == 'ftp'
+ subject.service.name.should == 'ftp'
end
- it "should parse the output of NSE scripts ran against the port" do
- @nse_port.scripts.should_not be_empty
+ context "when NSE scripts are ran" do
+ let(:xml) { XML.new(Helpers::NSE_FILE) }
- @nse_port.scripts.keys.should_not include(nil)
- @nse_port.scripts.values.should_not include(nil)
+ it "should parse the output of scripts" do
+ subject.scripts.should_not be_empty
+
+ subject.scripts.keys.should_not include(nil)
+ subject.scripts.values.should_not include(nil)
+ end
end
end