spec/shell_spec.rb in igp-0.0.3 vs spec/shell_spec.rb in igp-1.0.0

- old
+ new

@@ -1,161 +1,160 @@ require 'spec_helper' require 'getoptions' describe Igp::Shell do - - describe "base configuration" do + describe 'base configuration' do context 'without destination specified' do before do @options = GetOptions.new(Igp::Shell::OPTIONS, []) end - it "should initialize without error" do - expect { Igp::Shell.new(@options,[]) }.to_not raise_error + it 'should initialize without error' do + expect { Igp::Shell.new(@options, []) }.to_not raise_error end - it "should provide help/usage" do - Igp::Shell.respond_to?(:usage).should be_true - Igp::Shell.new(@options,[]).respond_to?(:usage).should be_true + it 'should provide help/usage' do + expect(Igp::Shell).to respond_to(:usage) + expect(Igp::Shell.new(@options, [])).to respond_to(:usage) end - it "should print usage when run" do - shell = Igp::Shell.new(@options,[]) - shell.should_receive(:usage) + it 'should print usage when run' do + shell = Igp::Shell.new(@options, []) + expect(shell).to receive(:usage) shell.run end end context 'with destination specified' do before do @options_server_value = 'example.com' @options = GetOptions.new(Igp::Shell::OPTIONS, []) - @shell = Igp::Shell.new(@options,[@options_server_value]) + @shell = Igp::Shell.new(@options, [@options_server_value]) end - it "should default to 1 second infinte intervals" do - @shell.options[:interval].should eql(1) - @shell.options[:limit].should be_nil + it 'should default to 1 second infinte intervals' do + expect(@shell.options[:interval]).to eql(1) + expect(@shell.options[:limit]).to be_nil end - it "should accept server and default to icmp ping" do - @shell.options[:host].should eql(@options_server_value) - @shell.options[:type].should eql(:icmp) + it 'should accept server and default to icmp ping' do + expect(@shell.options[:host]).to eql(@options_server_value) + expect(@shell.options[:type]).to eql(:icmp) end end end - - describe "tcp configuration" do + + describe 'tcp configuration' do before(:each) do @type = :tcp @host = 'localhost' @port = 843 - @options_server_value = "#{@type.to_s}://#{@host}:#{@port}" + @options_server_value = "#{@type}://#{@host}:#{@port}" @shell = Igp::Shell.new(GetOptions.new(Igp::Shell::OPTIONS, []), [@options_server_value]) end - it "should support url accessor" do - @shell.options[:url].should eql(@options_server_value) + it 'should support url accessor' do + expect(@shell.options[:url]).to eql(@options_server_value) end - it "should default to tcp ping with url when given server with tcp protocol setting" do - @shell.options[:type].should eql(@type) + it 'should default to tcp ping with url when given server with tcp protocol setting' do + expect(@shell.options[:type]).to eql(@type) end - it "should resolve host/port" do - @shell.options[:host].should eql(@host) - @shell.options[:port].should eql(@port) + it 'should resolve host/port' do + expect(@shell.options[:host]).to eql(@host) + expect(@shell.options[:port]).to eql(@port) end end - describe "udp configuration" do + describe 'udp configuration' do before(:each) do @type = :udp @host = 'localhost' @port = 22 - @options_server_value = "#{@type.to_s}://#{@host}:#{@port}" + @options_server_value = "#{@type}://#{@host}:#{@port}" @shell = Igp::Shell.new(GetOptions.new(Igp::Shell::OPTIONS, []), [@options_server_value]) end - it "should support url accessor" do - @shell.options[:url].should eql(@options_server_value) + it 'should support url accessor' do + expect(@shell.options[:url]).to eql(@options_server_value) end - it "should default to tcp ping with url when given server with tcp protocol setting" do - @shell.options[:type].should eql(@type) + it 'should default to tcp ping with url when given server with tcp protocol setting' do + expect(@shell.options[:type]).to eql(@type) end - it "should resolve host/port" do - @shell.options[:host].should eql(@host) - @shell.options[:port].should eql(@port) + it 'should resolve host/port' do + expect(@shell.options[:host]).to eql(@host) + expect(@shell.options[:port]).to eql(@port) end end - describe "http configuration" do + describe 'http configuration' do before(:each) do @type = :http @host = 'localhost' @port = 80 - @options_server_value = "#{@type.to_s}://#{@host}" + @options_server_value = "#{@type}://#{@host}" @shell = Igp::Shell.new(GetOptions.new(Igp::Shell::OPTIONS, []), [@options_server_value]) end - it "should support url accessor" do - @shell.options[:url].should eql(@options_server_value) + it 'should support url accessor' do + expect(@shell.options[:url]).to eql(@options_server_value) end - it "should default to tcp ping with url when given server with tcp protocol setting" do - @shell.options[:type].should eql(@type) + it 'should default to tcp ping with url when given server with tcp protocol setting' do + expect(@shell.options[:type]).to eql(@type) end - it "should resolve host/port" do - @shell.options[:host].should eql(@host) - @shell.options[:port].should eql(@port) + it 'should resolve host/port' do + expect(@shell.options[:host]).to eql(@host) + expect(@shell.options[:port]).to eql(@port) end end - describe "https configuration" do + describe 'https configuration' do before(:each) do @type = :https @host = 'localhost' @port = 443 - @options_server_value = "#{@type.to_s}://#{@host}" + @options_server_value = "#{@type}://#{@host}" @shell = Igp::Shell.new(GetOptions.new(Igp::Shell::OPTIONS, []), [@options_server_value]) end - it "should support url accessor" do - @shell.options[:url].should eql(@options_server_value) + it 'should support url accessor' do + expect(@shell.options[:url]).to eql(@options_server_value) end - it "should default to tcp ping with url when given server with tcp protocol setting" do - @shell.options[:type].should eql(@type) + it 'should default to tcp ping with url when given server with tcp protocol setting' do + expect(@shell.options[:type]).to eql(@type) end - it "should resolve host/port" do - @shell.options[:host].should eql(@host) - @shell.options[:port].should eql(@port) + it 'should resolve host/port' do + expect(@shell.options[:host]).to eql(@host) + expect(@shell.options[:port]).to eql(@port) end end - describe "ldap configuration" do - before(:each) do - @type = :ldap - @host = 'localhost' - @port = 389 - @options_server_value = "#{@type.to_s}://#{@host}" - @shell = Igp::Shell.new(GetOptions.new(Igp::Shell::OPTIONS, []), [@options_server_value]) - end - it "should support url accessor" do - @shell.options[:url].should eql(@options_server_value) - end - it "should default to tcp ping with url when given server with tcp protocol setting" do - @shell.options[:type].should eql(@type) - end - it "should resolve host/port" do - @shell.options[:host].should eql(@host) - @shell.options[:port].should eql(@port) - end - end + # TODO: LDAP was retired from net-ping. to add back in one way or another + # describe 'ldap configuration' do + # before(:each) do + # @type = :ldap + # @host = 'localhost' + # @port = 389 + # @options_server_value = "#{@type}://#{@host}" + # @shell = Igp::Shell.new(GetOptions.new(Igp::Shell::OPTIONS, []), [@options_server_value]) + # end + # it 'should support url accessor' do + # expect(@shell.options[:url]).to eql(@options_server_value) + # end + # it 'should default to tcp ping with url when given server with tcp protocol setting' do + # expect(@shell.options[:type]).to eql(@type) + # end + # it 'should resolve host/port' do + # expect(@shell.options[:host]).to eql(@host) + # expect(@shell.options[:port]).to eql(@port) + # end + # end - describe "ldaps configuration" do - before(:each) do - @type = :ldaps - @host = 'localhost' - @port = 636 - @options_server_value = "#{@type.to_s}://#{@host}" - @shell = Igp::Shell.new(GetOptions.new(Igp::Shell::OPTIONS, []), [@options_server_value]) - end - it "should support url accessor" do - @shell.options[:url].should eql(@options_server_value) - end - it "should default to tcp ping with url when given server with tcp protocol setting" do - @shell.options[:type].should eql(@type) - end - it "should resolve host/port" do - @shell.options[:host].should eql(@host) - @shell.options[:port].should eql(@port) - end - end - -end \ No newline at end of file + # describe 'ldaps configuration' do + # before(:each) do + # @type = :ldaps + # @host = 'localhost' + # @port = 636 + # @options_server_value = "#{@type}://#{@host}" + # @shell = Igp::Shell.new(GetOptions.new(Igp::Shell::OPTIONS, []), [@options_server_value]) + # end + # it 'should support url accessor' do + # expect(@shell.options[:url]).to eql(@options_server_value) + # end + # it 'should default to tcp ping with url when given server with tcp protocol setting' do + # expect(@shell.options[:type]).to eql(@type) + # end + # it 'should resolve host/port' do + # expect(@shell.options[:host]).to eql(@host) + # expect(@shell.options[:port]).to eql(@port) + # end + # end +end