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

- old
+ new

@@ -1,66 +1,66 @@ require 'spec_helper' require 'getoptions' describe Igp::Base do - - describe "base initialization without options" do - it "should not set ping_handler" do - subject.ping_handler.should be_nil + describe 'base initialization without options' do + it 'should not set ping_handler' do + expect(subject.ping_handler).to be_nil end - it "should not set limit" do - subject.limit.should be_nil + it 'should not set limit' do + expect(subject.limit).to be_nil end - it "should default interval to 5 sec" do - subject.interval.should eql(5) + it 'should default interval to 5 sec' do + expect(subject.interval).to eql(5) end end - - describe "ping_handler configuration" do - it "should be Net::Ping::External for :icmp" do - options = { :type => :icmp, :host => 'localhost', :port => nil} + + describe 'ping_handler configuration' do + it 'should be Net::Ping::External for :icmp' do + options = { type: :icmp, host: 'localhost', port: nil } base = Igp::Base.new(options) - base.ping_handler.should be_a(Net::Ping::External) + expect(base.ping_handler).to be_a(Net::Ping::External) end - it "should be Net::Ping::UDP for :tcp" do - options = { :type => :udp, :host => 'localhost', :port => 22} + it 'should be Net::Ping::UDP for :tcp' do + options = { type: :udp, host: 'localhost', port: 22 } base = Igp::Base.new(options) - base.ping_handler.should be_a(Net::Ping::UDP) + expect(base.ping_handler).to be_a(Net::Ping::UDP) end - it "should be Net::Ping::TCP for :tcp" do - options = { :type => :tcp, :host => 'localhost', :port => 22} + it 'should be Net::Ping::TCP for :tcp' do + options = { type: :tcp, host: 'localhost', port: 22 } base = Igp::Base.new(options) - base.ping_handler.should be_a(Net::Ping::TCP) + expect(base.ping_handler).to be_a(Net::Ping::TCP) end - it "should be Net::Ping::HTTP for :http" do - options = { :type => :http, :url => 'http://localhost'} + it 'should be Net::Ping::HTTP for :http' do + options = { type: :http, url: 'http://localhost' } base = Igp::Base.new(options) - base.ping_handler.should be_a(Net::Ping::HTTP) + expect(base.ping_handler).to be_a(Net::Ping::HTTP) end - it "should be Net::Ping::HTTP for :https" do - options = { :type => :https, :url => 'https://localhost'} + it 'should be Net::Ping::HTTP for :https' do + options = { type: :https, url: 'https://localhost' } base = Igp::Base.new(options) - base.ping_handler.should be_a(Net::Ping::HTTP) + expect(base.ping_handler).to be_a(Net::Ping::HTTP) end - it "should be Net::Ping::LDAP for :ldap" do - options = { :type => :ldap, :url => 'ldap://localhost'} - base = Igp::Base.new(options) - base.ping_handler.should be_a(Net::Ping::LDAP) - end - it "should be Net::Ping::LDAP for :ldaps" do - options = { :type => :ldaps, :url => 'ldaps://localhost'} - base = Igp::Base.new(options) - base.ping_handler.should be_a(Net::Ping::LDAP) - end + # TODO: LDAP was retired from net-ping. to add back in one way or another + # it 'should be Net::Ping::LDAP for :ldap' do + # options = { type: :ldap, url: 'ldap://localhost' } + # base = Igp::Base.new(options) + # expect(base.ping_handler).to be_a(Net::Ping::LDAP) + # end + # it 'should be Net::Ping::LDAP for :ldaps' do + # options = { type: :ldaps, url: 'ldaps://localhost' } + # base = Igp::Base.new(options) + # expect(base.ping_handler).to be_a(Net::Ping::LDAP) + # end end - describe "#run" do + describe '#run' do before do - @good = Igp::Base.new({ :type => :icmp, :host => 'localhost', :port => nil, :limit => 1}) + @good = Igp::Base.new({ type: :icmp, host: 'localhost', port: nil, limit: 1 }) end - it "should print header and log a ping result" do - @good.formatter.should_receive(:header) - @good.formatter.should_receive(:log) - capture(:stdout,:stderr){ @good.run } + it 'should print header and log a ping result' do + expect(@good.formatter).to receive(:header) + expect(@good.formatter).to receive(:log) + capture(:stdout, :stderr) { @good.run } end end -end \ No newline at end of file +end