summaryrefslogtreecommitdiff
path: root/spec/ruby/library/syslog
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/library/syslog')
-rw-r--r--spec/ruby/library/syslog/close_spec.rb16
-rw-r--r--spec/ruby/library/syslog/constants_spec.rb4
-rw-r--r--spec/ruby/library/syslog/facility_spec.rb6
-rw-r--r--spec/ruby/library/syslog/ident_spec.rb4
-rw-r--r--spec/ruby/library/syslog/inspect_spec.rb4
-rw-r--r--spec/ruby/library/syslog/log_spec.rb10
-rw-r--r--spec/ruby/library/syslog/mask_spec.rb14
-rw-r--r--spec/ruby/library/syslog/open_spec.rb48
-rw-r--r--spec/ruby/library/syslog/opened_spec.rb16
-rw-r--r--spec/ruby/library/syslog/options_spec.rb6
-rw-r--r--spec/ruby/library/syslog/reopen_spec.rb5
-rw-r--r--spec/ruby/library/syslog/shared/log.rb6
-rw-r--r--spec/ruby/library/syslog/shared/reopen.rb40
13 files changed, 87 insertions, 92 deletions
diff --git a/spec/ruby/library/syslog/close_spec.rb b/spec/ruby/library/syslog/close_spec.rb
index 8c3b67c05b..713ef701d2 100644
--- a/spec/ruby/library/syslog/close_spec.rb
+++ b/spec/ruby/library/syslog/close_spec.rb
@@ -7,29 +7,29 @@ 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)
+ }.should.raise(RuntimeError)
Syslog.should_not.opened?
end
@@ -37,7 +37,7 @@ platform_is_not :windows 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 3b08327140..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
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 8589fb1f73..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
@@ -34,14 +34,14 @@ platform_is_not :windows do
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
diff --git a/spec/ruby/library/syslog/mask_spec.rb b/spec/ruby/library/syslog/mask_spec.rb
index b3f1250b24..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
@@ -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..3aceea007d 100644
--- a/spec/ruby/library/syslog/open_spec.rb
+++ b/spec/ruby/library/syslog/open_spec.rb
@@ -1,18 +1,17 @@
require_relative '../../spec_helper'
platform_is_not :windows do
- 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,24 +68,59 @@ 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
end
describe "Syslog.open!" do
- it_behaves_like :syslog_reopen, :open!
+ before :each do
+ Syslog.opened?.should == false
+ end
+
+ after :each do
+ Syslog.opened?.should == false
+ end
+
+ it "reopens the log" do
+ Syslog.open
+ -> { Syslog.open! }.should_not.raise
+ Syslog.opened?.should == true
+ Syslog.close
+ end
+
+ it "fails with RuntimeError if the log is closed" do
+ -> { Syslog.open! }.should.raise(RuntimeError)
+ end
+
+ it "receives the same parameters as Syslog.open" do
+ Syslog.open
+ Syslog.open!("rubyspec", 3, 8) do |s|
+ s.should == Syslog
+ s.ident.should == "rubyspec"
+ s.options.should == 3
+ s.facility.should == Syslog::LOG_USER
+ s.opened?.should == true
+ end
+ Syslog.opened?.should == false
+ end
+
+ it "returns the module" do
+ Syslog.open
+ Syslog.open!.should == Syslog
+ Syslog.close
+ end
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/reopen_spec.rb b/spec/ruby/library/syslog/reopen_spec.rb
index a78529fa1f..ef32d13a87 100644
--- a/spec/ruby/library/syslog/reopen_spec.rb
+++ b/spec/ruby/library/syslog/reopen_spec.rb
@@ -1,10 +1,11 @@
require_relative '../../spec_helper'
platform_is_not :windows do
- require_relative 'shared/reopen'
require 'syslog'
describe "Syslog.reopen" do
- it_behaves_like :syslog_reopen, :reopen
+ it "is an alias of Syslog.open!" do
+ Syslog.method(:reopen).should == Syslog.method(:open!)
+ end
end
end
diff --git a/spec/ruby/library/syslog/shared/log.rb b/spec/ruby/library/syslog/shared/log.rb
index 12e4ea8366..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
diff --git a/spec/ruby/library/syslog/shared/reopen.rb b/spec/ruby/library/syslog/shared/reopen.rb
deleted file mode 100644
index 621437a01d..0000000000
--- a/spec/ruby/library/syslog/shared/reopen.rb
+++ /dev/null
@@ -1,40 +0,0 @@
-describe :syslog_reopen, shared: true do
- platform_is_not :windows do
- before :each do
- Syslog.opened?.should be_false
- end
-
- after :each do
- Syslog.opened?.should be_false
- end
-
- it "reopens the log" do
- Syslog.open
- -> { Syslog.send(@method)}.should_not raise_error
- Syslog.opened?.should be_true
- Syslog.close
- end
-
- it "fails with RuntimeError if the log is closed" do
- -> { Syslog.send(@method)}.should raise_error(RuntimeError)
- end
-
- it "receives the same parameters as Syslog.open" do
- Syslog.open
- Syslog.send(@method, "rubyspec", 3, 8) do |s|
- s.should == Syslog
- s.ident.should == "rubyspec"
- s.options.should == 3
- s.facility.should == Syslog::LOG_USER
- s.opened?.should be_true
- end
- Syslog.opened?.should be_false
- end
-
- it "returns the module" do
- Syslog.open
- Syslog.send(@method).should == Syslog
- Syslog.close
- end
- end
-end