diff options
Diffstat (limited to 'spec/ruby/library/syslog')
| -rw-r--r-- | spec/ruby/library/syslog/close_spec.rb | 18 | ||||
| -rw-r--r-- | spec/ruby/library/syslog/constants_spec.rb | 4 | ||||
| -rw-r--r-- | spec/ruby/library/syslog/facility_spec.rb | 6 | ||||
| -rw-r--r-- | spec/ruby/library/syslog/ident_spec.rb | 6 | ||||
| -rw-r--r-- | spec/ruby/library/syslog/inspect_spec.rb | 4 | ||||
| -rw-r--r-- | spec/ruby/library/syslog/log_spec.rb | 16 | ||||
| -rw-r--r-- | spec/ruby/library/syslog/mask_spec.rb | 16 | ||||
| -rw-r--r-- | spec/ruby/library/syslog/open_spec.rb | 10 | ||||
| -rw-r--r-- | spec/ruby/library/syslog/opened_spec.rb | 16 | ||||
| -rw-r--r-- | spec/ruby/library/syslog/options_spec.rb | 6 | ||||
| -rw-r--r-- | spec/ruby/library/syslog/shared/log.rb | 13 | ||||
| -rw-r--r-- | spec/ruby/library/syslog/shared/reopen.rb | 14 |
12 files changed, 64 insertions, 65 deletions
diff --git a/spec/ruby/library/syslog/close_spec.rb b/spec/ruby/library/syslog/close_spec.rb index 8186ecf125..713ef701d2 100644 --- a/spec/ruby/library/syslog/close_spec.rb +++ b/spec/ruby/library/syslog/close_spec.rb @@ -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 - -> { Syslog.close }.should raise_error(RuntimeError) + -> { Syslog.close }.should.raise(RuntimeError) end it "it does not work inside blocks" do -> { 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 2b9524c53d..a6ac355ddd 100644 --- a/spec/ruby/library/syslog/constants_spec.rb +++ b/spec/ruby/library/syslog/constants_spec.rb @@ -4,7 +4,7 @@ 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/facility_spec.rb b/spec/ruby/library/syslog/facility_spec.rb index 550ca70b11..79a685c201 100644 --- a/spec/ruby/library/syslog/facility_spec.rb +++ b/spec/ruby/library/syslog/facility_spec.rb @@ -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 e8345ebb49..80302a42b8 100644 --- a/spec/ruby/library/syslog/ident_spec.rb +++ b/spec/ruby/library/syslog/ident_spec.rb @@ -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/inspect_spec.rb b/spec/ruby/library/syslog/inspect_spec.rb index f45231f8e3..6407423fd3 100644 --- a/spec/ruby/library/syslog/inspect_spec.rb +++ b/spec/ruby/library/syslog/inspect_spec.rb @@ -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/log_spec.rb b/spec/ruby/library/syslog/log_spec.rb index d0eaea2a94..1650283371 100644 --- a/spec/ruby/library/syslog/log_spec.rb +++ b/spec/ruby/library/syslog/log_spec.rb @@ -4,14 +4,14 @@ platform_is_not :windows do require 'syslog' describe "Syslog.log" do - platform_is_not :windows, :darwin, :solaris, :aix, :android 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 @@ -20,7 +20,7 @@ platform_is_not :windows do 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 priorities" do @@ -29,19 +29,19 @@ platform_is_not :windows do 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| - -> { 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 -> { Syslog.log(Syslog::LOG_ALERT, "test") - }.should raise_error(RuntimeError) + }.should.raise(RuntimeError) end it "accepts printf parameters" do @@ -49,7 +49,7 @@ platform_is_not :windows do 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 6581f6a756..23cca6fa8d 100644 --- a/spec/ruby/library/syslog/mask_spec.rb +++ b/spec/ruby/library/syslog/mask_spec.rb @@ -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 - -> { 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 - -> { Syslog.mask = "oh hai" }.should raise_error(TypeError) - -> { 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/open_spec.rb b/spec/ruby/library/syslog/open_spec.rb index 543f5d418b..73e3780d78 100644 --- a/spec/ruby/library/syslog/open_spec.rb +++ b/spec/ruby/library/syslog/open_spec.rb @@ -8,11 +8,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 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 -> { Syslog.open - }.should raise_error(RuntimeError, /syslog already open/) + }.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 94432e65a4..ad4311d15a 100644 --- a/spec/ruby/library/syslog/opened_spec.rb +++ b/spec/ruby/library/syslog/opened_spec.rb @@ -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 83ba43503e..2035272f70 100644 --- a/spec/ruby/library/syslog/options_spec.rb +++ b/spec/ruby/library/syslog/options_spec.rb @@ -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/shared/log.rb b/spec/ruby/library/syslog/shared/log.rb index c77ff6dd95..98ce4f54b2 100644 --- a/spec/ruby/library/syslog/shared/log.rb +++ b/spec/ruby/library/syslog/shared/log.rb @@ -1,11 +1,11 @@ describe :syslog_log, shared: true do - platform_is_not :windows, :darwin, :solaris, :aix, :android 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 @@ -13,7 +13,7 @@ describe :syslog_log, shared: true do 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 @@ -22,19 +22,18 @@ describe :syslog_log, shared: true 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" -> { 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 621437a01d..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 - -> { 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 - -> { 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 |
