diff options
Diffstat (limited to 'spec/ruby/library/syslog')
22 files changed, 105 insertions, 106 deletions
diff --git a/spec/ruby/library/syslog/alert_spec.rb b/spec/ruby/library/syslog/alert_spec.rb index e61b3d6ef3..edff789dc9 100644 --- a/spec/ruby/library/syslog/alert_spec.rb +++ b/spec/ruby/library/syslog/alert_spec.rb @@ -1,7 +1,7 @@ -require File.expand_path('../../../spec_helper', __FILE__) +require_relative '../../spec_helper' platform_is_not :windows do - require File.expand_path('../shared/log', __FILE__) + require_relative 'shared/log' require 'syslog' describe "Syslog.alert" do diff --git a/spec/ruby/library/syslog/close_spec.rb b/spec/ruby/library/syslog/close_spec.rb index d7aadb2198..713ef701d2 100644 --- a/spec/ruby/library/syslog/close_spec.rb +++ b/spec/ruby/library/syslog/close_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../spec_helper', __FILE__) +require_relative '../../spec_helper' platform_is_not :windows do require 'syslog' @@ -7,37 +7,37 @@ platform_is_not :windows do platform_is_not :windows do before :each do - Syslog.opened?.should be_false + Syslog.opened?.should == false end after :each do - Syslog.opened?.should be_false + Syslog.opened?.should == false end it "closes the log" do - Syslog.opened?.should be_false + Syslog.opened?.should == false Syslog.open - Syslog.opened?.should be_true + Syslog.opened?.should == true Syslog.close - Syslog.opened?.should be_false + Syslog.opened?.should == false end it "raises a RuntimeError if the log's already closed" do - lambda { Syslog.close }.should raise_error(RuntimeError) + -> { Syslog.close }.should.raise(RuntimeError) end it "it does not work inside blocks" do - lambda { + -> { Syslog.open { |s| s.close } - }.should raise_error(RuntimeError) - Syslog.opened?.should == false + }.should.raise(RuntimeError) + Syslog.should_not.opened? end it "sets the identity to nil" do Syslog.open("rubyspec") Syslog.ident.should == "rubyspec" Syslog.close - Syslog.ident.should be_nil + Syslog.ident.should == nil end it "sets the options to nil" do diff --git a/spec/ruby/library/syslog/constants_spec.rb b/spec/ruby/library/syslog/constants_spec.rb index 1ce82be883..a6ac355ddd 100644 --- a/spec/ruby/library/syslog/constants_spec.rb +++ b/spec/ruby/library/syslog/constants_spec.rb @@ -1,10 +1,10 @@ -require File.expand_path('../../../spec_helper', __FILE__) +require_relative '../../spec_helper' platform_is_not :windows do require 'syslog' describe "Syslog::Constants" do - platform_is_not :windows, :solaris, :aix do + platform_is_not :windows, :aix do before :all do @constants = %w(LOG_AUTHPRIV LOG_USER LOG_LOCAL2 LOG_NOTICE LOG_NDELAY LOG_SYSLOG LOG_ALERT LOG_FTP LOG_LOCAL5 LOG_ERR LOG_AUTH @@ -17,7 +17,7 @@ platform_is_not :windows do it "includes the Syslog constants" do @constants.each do |c| - Syslog::Constants.should have_constant(c) + Syslog::Constants.should.const_defined?(c, true) end end end diff --git a/spec/ruby/library/syslog/crit_spec.rb b/spec/ruby/library/syslog/crit_spec.rb index cf2cc71abc..5d3904f719 100644 --- a/spec/ruby/library/syslog/crit_spec.rb +++ b/spec/ruby/library/syslog/crit_spec.rb @@ -1,7 +1,7 @@ -require File.expand_path('../../../spec_helper', __FILE__) +require_relative '../../spec_helper' platform_is_not :windows do - require File.expand_path('../shared/log', __FILE__) + require_relative 'shared/log' require 'syslog' describe "Syslog.crit" do diff --git a/spec/ruby/library/syslog/debug_spec.rb b/spec/ruby/library/syslog/debug_spec.rb index 09ba9997a2..d03e8a88c9 100644 --- a/spec/ruby/library/syslog/debug_spec.rb +++ b/spec/ruby/library/syslog/debug_spec.rb @@ -1,7 +1,7 @@ -require File.expand_path('../../../spec_helper', __FILE__) +require_relative '../../spec_helper' platform_is_not :windows do - require File.expand_path('../shared/log', __FILE__) + require_relative 'shared/log' require 'syslog' describe "Syslog.debug" do diff --git a/spec/ruby/library/syslog/emerg_spec.rb b/spec/ruby/library/syslog/emerg_spec.rb index d416ee57c6..2ab4d60291 100644 --- a/spec/ruby/library/syslog/emerg_spec.rb +++ b/spec/ruby/library/syslog/emerg_spec.rb @@ -1,7 +1,7 @@ -require File.expand_path('../../../spec_helper', __FILE__) +require_relative '../../spec_helper' platform_is_not :windows do - require File.expand_path('../shared/log', __FILE__) + require_relative 'shared/log' require 'syslog' describe "Syslog.emerg" do diff --git a/spec/ruby/library/syslog/err_spec.rb b/spec/ruby/library/syslog/err_spec.rb index ad65f6c276..43e876ed37 100644 --- a/spec/ruby/library/syslog/err_spec.rb +++ b/spec/ruby/library/syslog/err_spec.rb @@ -1,7 +1,7 @@ -require File.expand_path('../../../spec_helper', __FILE__) +require_relative '../../spec_helper' platform_is_not :windows do - require File.expand_path('../shared/log', __FILE__) + require_relative 'shared/log' require 'syslog' describe "Syslog.err" do diff --git a/spec/ruby/library/syslog/facility_spec.rb b/spec/ruby/library/syslog/facility_spec.rb index fdcabfa0dd..79a685c201 100644 --- a/spec/ruby/library/syslog/facility_spec.rb +++ b/spec/ruby/library/syslog/facility_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../spec_helper', __FILE__) +require_relative '../../spec_helper' platform_is_not :windows do require 'syslog' @@ -7,11 +7,11 @@ platform_is_not :windows do platform_is_not :windows do before :each do - Syslog.opened?.should be_false + Syslog.opened?.should == false end after :each do - Syslog.opened?.should be_false + Syslog.opened?.should == false end it "returns the logging facility" do @@ -21,7 +21,7 @@ platform_is_not :windows do end it "returns nil if the log is closed" do - Syslog.opened?.should be_false + Syslog.opened?.should == false Syslog.facility.should == nil end diff --git a/spec/ruby/library/syslog/ident_spec.rb b/spec/ruby/library/syslog/ident_spec.rb index ef1144f12e..80302a42b8 100644 --- a/spec/ruby/library/syslog/ident_spec.rb +++ b/spec/ruby/library/syslog/ident_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../spec_helper', __FILE__) +require_relative '../../spec_helper' platform_is_not :windows do require 'syslog' @@ -7,11 +7,11 @@ platform_is_not :windows do platform_is_not :windows do before :each do - Syslog.opened?.should be_false + Syslog.opened?.should == false end after :each do - Syslog.opened?.should be_false + Syslog.opened?.should == false end it "returns the logging identity" do @@ -21,7 +21,7 @@ platform_is_not :windows do end it "returns nil if the log is closed" do - Syslog.opened?.should == false + Syslog.should_not.opened? Syslog.ident.should == nil end diff --git a/spec/ruby/library/syslog/info_spec.rb b/spec/ruby/library/syslog/info_spec.rb index b2abe7c04a..f2d535299c 100644 --- a/spec/ruby/library/syslog/info_spec.rb +++ b/spec/ruby/library/syslog/info_spec.rb @@ -1,7 +1,7 @@ -require File.expand_path('../../../spec_helper', __FILE__) +require_relative '../../spec_helper' platform_is_not :windows do - require File.expand_path('../shared/log', __FILE__) + require_relative 'shared/log' require 'syslog' describe "Syslog.info" do diff --git a/spec/ruby/library/syslog/inspect_spec.rb b/spec/ruby/library/syslog/inspect_spec.rb index c22a053286..6407423fd3 100644 --- a/spec/ruby/library/syslog/inspect_spec.rb +++ b/spec/ruby/library/syslog/inspect_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../spec_helper', __FILE__) +require_relative '../../spec_helper' platform_is_not :windows do require 'syslog' @@ -7,11 +7,11 @@ platform_is_not :windows do platform_is_not :windows do before :each do - Syslog.opened?.should be_false + Syslog.opened?.should == false end after :each do - Syslog.opened?.should be_false + Syslog.opened?.should == false end it "returns a string a closed log" do diff --git a/spec/ruby/library/syslog/instance_spec.rb b/spec/ruby/library/syslog/instance_spec.rb index 65d97a5d50..891296c52d 100644 --- a/spec/ruby/library/syslog/instance_spec.rb +++ b/spec/ruby/library/syslog/instance_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../spec_helper', __FILE__) +require_relative '../../spec_helper' platform_is_not :windows do require 'syslog' diff --git a/spec/ruby/library/syslog/log_spec.rb b/spec/ruby/library/syslog/log_spec.rb index eac6be8b01..1650283371 100644 --- a/spec/ruby/library/syslog/log_spec.rb +++ b/spec/ruby/library/syslog/log_spec.rb @@ -1,55 +1,55 @@ -require File.expand_path('../../../spec_helper', __FILE__) +require_relative '../../spec_helper' platform_is_not :windows do require 'syslog' describe "Syslog.log" do - platform_is_not :windows, :darwin, :solaris, :aix do + platform_is_not :windows, :darwin, :aix, :android do before :each do - Syslog.opened?.should be_false + Syslog.opened?.should == false end after :each do - Syslog.opened?.should be_false + Syslog.opened?.should == false end it "receives a priority as first argument" do - lambda { + -> { Syslog.open("rubyspec", Syslog::LOG_PERROR) do |s| s.log(Syslog::LOG_ALERT, "Hello") s.log(Syslog::LOG_CRIT, "World") end - }.should output_to_fd("rubyspec: Hello\nrubyspec: World\n", $stderr) + }.should output_to_fd(/\Arubyspec(?::| \d+ - -) Hello\nrubyspec(?::| \d+ - -) World\n\z/, $stderr) end - it "accepts undefined priorites" do - lambda { + it "accepts undefined priorities" do + -> { Syslog.open("rubyspec", Syslog::LOG_PERROR) do |s| s.log(1337, "Hello") end # use a regex since it'll output unknown facility/priority messages - }.should output_to_fd(/rubyspec: Hello/, $stderr) + }.should output_to_fd(/rubyspec(?::| \d+ - -) Hello\n\z/, $stderr) end it "fails with TypeError on nil log messages" do Syslog.open do |s| - lambda { s.log(1, nil) }.should raise_error(TypeError) + -> { s.log(1, nil) }.should.raise(TypeError) end end it "fails if the log is closed" do - lambda { + -> { Syslog.log(Syslog::LOG_ALERT, "test") - }.should raise_error(RuntimeError) + }.should.raise(RuntimeError) end it "accepts printf parameters" do - lambda { + -> { Syslog.open("rubyspec", Syslog::LOG_PERROR) do |s| s.log(Syslog::LOG_ALERT, "%s x %d", "chunky bacon", 2) end - }.should output_to_fd("rubyspec: chunky bacon x 2\n", $stderr) + }.should output_to_fd(/rubyspec(?::| \d+ - -) chunky bacon x 2\n\z/, $stderr) end end end diff --git a/spec/ruby/library/syslog/mask_spec.rb b/spec/ruby/library/syslog/mask_spec.rb index 7a11d1e88c..23cca6fa8d 100644 --- a/spec/ruby/library/syslog/mask_spec.rb +++ b/spec/ruby/library/syslog/mask_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../spec_helper', __FILE__) +require_relative '../../spec_helper' platform_is_not :windows do require 'syslog' @@ -7,11 +7,11 @@ platform_is_not :windows do platform_is_not :windows do before :each do - Syslog.opened?.should be_false + Syslog.opened?.should == false end after :each do - Syslog.opened?.should be_false + Syslog.opened?.should == false # make sure we return the mask to the default value Syslog.open { |s| s.mask = 255 } end @@ -32,7 +32,7 @@ platform_is_not :windows do end it "returns nil if the log is closed" do - Syslog.opened?.should == false + Syslog.should_not.opened? Syslog.mask.should == nil end @@ -74,11 +74,11 @@ platform_is_not :windows do platform_is_not :windows do before :each do - Syslog.opened?.should be_false + Syslog.opened?.should == false end after :each do - Syslog.opened?.should be_false + Syslog.opened?.should == false # make sure we return the mask to the default value Syslog.open { |s| s.mask = 255 } end @@ -91,7 +91,7 @@ platform_is_not :windows do end it "raises an error if the log is closed" do - lambda { Syslog.mask = 1337 }.should raise_error(RuntimeError) + -> { Syslog.mask = 1337 }.should.raise(RuntimeError) end it "only accepts numbers" do @@ -103,8 +103,8 @@ platform_is_not :windows do Syslog.mask = 3.1416 Syslog.mask.should == 3 - lambda { Syslog.mask = "oh hai" }.should raise_error(TypeError) - lambda { Syslog.mask = "43" }.should raise_error(TypeError) + -> { Syslog.mask = "oh hai" }.should.raise(TypeError) + -> { Syslog.mask = "43" }.should.raise(TypeError) end end diff --git a/spec/ruby/library/syslog/notice_spec.rb b/spec/ruby/library/syslog/notice_spec.rb index f31074f3f6..a2134e0140 100644 --- a/spec/ruby/library/syslog/notice_spec.rb +++ b/spec/ruby/library/syslog/notice_spec.rb @@ -1,7 +1,7 @@ -require File.expand_path('../../../spec_helper', __FILE__) +require_relative '../../spec_helper' platform_is_not :windows do - require File.expand_path('../shared/log', __FILE__) + require_relative 'shared/log' require 'syslog' describe "Syslog.notice" do diff --git a/spec/ruby/library/syslog/open_spec.rb b/spec/ruby/library/syslog/open_spec.rb index 424b48d831..73e3780d78 100644 --- a/spec/ruby/library/syslog/open_spec.rb +++ b/spec/ruby/library/syslog/open_spec.rb @@ -1,18 +1,18 @@ -require File.expand_path('../../../spec_helper', __FILE__) +require_relative '../../spec_helper' platform_is_not :windows do - require File.expand_path('../shared/reopen', __FILE__) + require_relative 'shared/reopen' require 'syslog' describe "Syslog.open" do platform_is_not :windows do before :each do - Syslog.opened?.should be_false + Syslog.opened?.should == false end after :each do - Syslog.opened?.should be_false + Syslog.opened?.should == false end it "returns the module" do @@ -69,18 +69,18 @@ platform_is_not :windows do it "closes the log if after it receives a block" do Syslog.open{ } - Syslog.opened?.should be_false + Syslog.opened?.should == false end it "raises an error if the log is opened" do Syslog.open - lambda { + -> { Syslog.open - }.should raise_error(RuntimeError, /syslog already open/) - lambda { + }.should.raise(RuntimeError, /syslog already open/) + -> { Syslog.close Syslog.open - }.should_not raise_error + }.should_not.raise Syslog.close end end diff --git a/spec/ruby/library/syslog/opened_spec.rb b/spec/ruby/library/syslog/opened_spec.rb index 1db388fa61..ad4311d15a 100644 --- a/spec/ruby/library/syslog/opened_spec.rb +++ b/spec/ruby/library/syslog/opened_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../spec_helper', __FILE__) +require_relative '../../spec_helper' platform_is_not :windows do require 'syslog' @@ -7,32 +7,32 @@ platform_is_not :windows do platform_is_not :windows do before :each do - Syslog.opened?.should be_false + Syslog.opened?.should == false end after :each do - Syslog.opened?.should be_false + Syslog.opened?.should == false end it "returns true if the log is opened" do Syslog.open - Syslog.opened?.should be_true + Syslog.opened?.should == true Syslog.close end it "returns false otherwise" do - Syslog.opened?.should be_false + Syslog.opened?.should == false Syslog.open Syslog.close - Syslog.opened?.should be_false + Syslog.opened?.should == false end it "works inside a block" do Syslog.open do |s| - s.opened?.should be_true - Syslog.opened?.should be_true + s.opened?.should == true + Syslog.opened?.should == true end - Syslog.opened?.should be_false + Syslog.opened?.should == false end end end diff --git a/spec/ruby/library/syslog/options_spec.rb b/spec/ruby/library/syslog/options_spec.rb index 145d11a2fb..2035272f70 100644 --- a/spec/ruby/library/syslog/options_spec.rb +++ b/spec/ruby/library/syslog/options_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../spec_helper', __FILE__) +require_relative '../../spec_helper' platform_is_not :windows do require 'syslog' @@ -7,11 +7,11 @@ platform_is_not :windows do platform_is_not :windows do before :each do - Syslog.opened?.should be_false + Syslog.opened?.should == false end after :each do - Syslog.opened?.should be_false + Syslog.opened?.should == false end it "returns the logging options" do @@ -21,7 +21,7 @@ platform_is_not :windows do end it "returns nil when the log is closed" do - Syslog.opened?.should be_false + Syslog.opened?.should == false Syslog.options.should == nil end diff --git a/spec/ruby/library/syslog/reopen_spec.rb b/spec/ruby/library/syslog/reopen_spec.rb index 49704784e5..a78529fa1f 100644 --- a/spec/ruby/library/syslog/reopen_spec.rb +++ b/spec/ruby/library/syslog/reopen_spec.rb @@ -1,7 +1,7 @@ -require File.expand_path('../../../spec_helper', __FILE__) +require_relative '../../spec_helper' platform_is_not :windows do - require File.expand_path('../shared/reopen', __FILE__) + require_relative 'shared/reopen' require 'syslog' describe "Syslog.reopen" do diff --git a/spec/ruby/library/syslog/shared/log.rb b/spec/ruby/library/syslog/shared/log.rb index 6d0d3a3c23..98ce4f54b2 100644 --- a/spec/ruby/library/syslog/shared/log.rb +++ b/spec/ruby/library/syslog/shared/log.rb @@ -1,40 +1,39 @@ describe :syslog_log, shared: true do - platform_is_not :windows, :darwin, :solaris, :aix do + platform_is_not :windows, :darwin, :aix, :android do before :each do - Syslog.opened?.should be_false + Syslog.opened?.should == false end after :each do - Syslog.opened?.should be_false + Syslog.opened?.should == false end it "logs a message" do - lambda { + -> { Syslog.open("rubyspec", Syslog::LOG_PERROR) do Syslog.send(@method, "Hello") end - }.should output_to_fd("rubyspec: Hello\n", $stderr) + }.should output_to_fd(/\Arubyspec(?::| \d+ - -) Hello\n\z/, $stderr) end it "accepts sprintf arguments" do - lambda { + -> { Syslog.open("rubyspec", Syslog::LOG_PERROR) do Syslog.send(@method, "Hello %s", "world") Syslog.send(@method, "%d dogs", 2) end - }.should output_to_fd("rubyspec: Hello world\nrubyspec: 2 dogs\n", $stderr) + }.should output_to_fd(/\Arubyspec(?::| \d+ - -) Hello world\nrubyspec(?::| \d+ - -) 2 dogs\n\z/, $stderr) end it "works as an alias for Syslog.log" do level = Syslog.const_get "LOG_#{@method.to_s.upcase}" - response = "rubyspec: Hello\n" - lambda { + -> { Syslog.open("rubyspec", Syslog::LOG_PERROR) do Syslog.send(@method, "Hello") Syslog.log(level, "Hello") end # make sure the same thing is written to $stderr. - }.should output_to_fd(response * 2, $stderr) + }.should output_to_fd(/\A(?:rubyspec(?::| \d+ - -) Hello\n){2}\z/, $stderr) end end end diff --git a/spec/ruby/library/syslog/shared/reopen.rb b/spec/ruby/library/syslog/shared/reopen.rb index fd30ab824a..f04408e807 100644 --- a/spec/ruby/library/syslog/shared/reopen.rb +++ b/spec/ruby/library/syslog/shared/reopen.rb @@ -1,22 +1,22 @@ describe :syslog_reopen, shared: true do platform_is_not :windows do before :each do - Syslog.opened?.should be_false + Syslog.opened?.should == false end after :each do - Syslog.opened?.should be_false + Syslog.opened?.should == false end it "reopens the log" do Syslog.open - lambda { Syslog.send(@method)}.should_not raise_error - Syslog.opened?.should be_true + -> { Syslog.send(@method)}.should_not.raise + Syslog.opened?.should == true Syslog.close end it "fails with RuntimeError if the log is closed" do - lambda { Syslog.send(@method)}.should raise_error(RuntimeError) + -> { Syslog.send(@method)}.should.raise(RuntimeError) end it "receives the same parameters as Syslog.open" do @@ -26,9 +26,9 @@ describe :syslog_reopen, shared: true do s.ident.should == "rubyspec" s.options.should == 3 s.facility.should == Syslog::LOG_USER - s.opened?.should be_true + s.opened?.should == true end - Syslog.opened?.should be_false + Syslog.opened?.should == false end it "returns the module" do diff --git a/spec/ruby/library/syslog/warning_spec.rb b/spec/ruby/library/syslog/warning_spec.rb index 31fa9524f7..eeca603136 100644 --- a/spec/ruby/library/syslog/warning_spec.rb +++ b/spec/ruby/library/syslog/warning_spec.rb @@ -1,7 +1,7 @@ -require File.expand_path('../../../spec_helper', __FILE__) +require_relative '../../spec_helper' platform_is_not :windows do - require File.expand_path('../shared/log', __FILE__) + require_relative 'shared/log' require 'syslog' describe "Syslog.warning" do |
