diff options
author | eregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-05-07 12:04:49 +0000 |
---|---|---|
committer | eregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-05-07 12:04:49 +0000 |
commit | 95e8c48dd3348503a8c7db5d0498894a1b676395 (patch) | |
tree | 9eef7f720314ebaff56845a74e203770e62284e4 /spec/rubyspec/library/syslog | |
parent | ed7d803500de38186c74bce94d233e85ef51e503 (diff) | |
download | ruby-95e8c48dd3348503a8c7db5d0498894a1b676395.tar.gz |
Add in-tree mspec and ruby/spec
* For easier modifications of ruby/spec by MRI developers.
* .gitignore: track changes under spec.
* spec/mspec, spec/rubyspec: add in-tree mspec and ruby/spec.
These files can therefore be updated like any other file in MRI.
Instructions are provided in spec/README.
[Feature #13156] [ruby-core:79246]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58595 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'spec/rubyspec/library/syslog')
22 files changed, 733 insertions, 0 deletions
diff --git a/spec/rubyspec/library/syslog/alert_spec.rb b/spec/rubyspec/library/syslog/alert_spec.rb new file mode 100644 index 0000000000..4653fa8636 --- /dev/null +++ b/spec/rubyspec/library/syslog/alert_spec.rb @@ -0,0 +1,9 @@ +platform_is_not :windows do + require File.expand_path('../../../spec_helper', __FILE__) + require File.expand_path('../shared/log', __FILE__) + require 'syslog' + + describe "Syslog.alert" do + it_behaves_like :syslog_log, :alert + end +end diff --git a/spec/rubyspec/library/syslog/close_spec.rb b/spec/rubyspec/library/syslog/close_spec.rb new file mode 100644 index 0000000000..f7bc4ac6e9 --- /dev/null +++ b/spec/rubyspec/library/syslog/close_spec.rb @@ -0,0 +1,57 @@ +platform_is_not :windows do + require File.expand_path('../../../spec_helper', __FILE__) + require 'syslog' + + describe "Syslog.close" 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 "closes the log" do + Syslog.opened?.should be_false + Syslog.open + Syslog.opened?.should be_true + Syslog.close + Syslog.opened?.should be_false + end + + it "raises a RuntimeError if the log's already closed" do + lambda { Syslog.close }.should raise_error(RuntimeError) + end + + it "it does not work inside blocks" do + lambda { + Syslog.open { |s| s.close } + }.should raise_error(RuntimeError) + Syslog.opened?.should == false + end + + it "sets the identity to nil" do + Syslog.open("rubyspec") + Syslog.ident.should == "rubyspec" + Syslog.close + Syslog.ident.should be_nil + end + + it "sets the options to nil" do + Syslog.open("rubyspec", Syslog::LOG_PID) + Syslog.options.should == Syslog::LOG_PID + Syslog.close + Syslog.options.should == nil + end + + it "sets the facility to nil" do + Syslog.open + Syslog.facility.should == 8 + Syslog.close + Syslog.facility.should == nil + end + end + end +end diff --git a/spec/rubyspec/library/syslog/constants_spec.rb b/spec/rubyspec/library/syslog/constants_spec.rb new file mode 100644 index 0000000000..c335ff46e6 --- /dev/null +++ b/spec/rubyspec/library/syslog/constants_spec.rb @@ -0,0 +1,40 @@ +platform_is_not :windows do + require File.expand_path('../../../spec_helper', __FILE__) + require 'syslog' + + describe "Syslog::Constants" do + platform_is_not :windows, :solaris, :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 + LOG_LOCAL1 LOG_ODELAY LOG_NEWS LOG_DAEMON LOG_LOCAL4 + LOG_CRIT LOG_INFO LOG_PERROR LOG_LOCAL0 LOG_CONS LOG_LPR + LOG_LOCAL7 LOG_WARNING LOG_CRON LOG_LOCAL3 LOG_EMERG + LOG_NOWAIT LOG_UUCP LOG_PID LOG_KERN LOG_MAIL LOG_LOCAL6 + LOG_DEBUG) + end + + it "includes the Syslog constants" do + @constants.each do |c| + Syslog::Constants.should have_constant(c) + end + end + end + + # The masks are defined in <syslog.h> + + describe "Syslog::Constants.LOG_MASK" do + it "returns the mask value for a priority" do + Syslog::Constants.LOG_MASK(Syslog::LOG_DEBUG).should == 128 + Syslog::Constants.LOG_MASK(Syslog::LOG_WARNING).should == 16 + end + end + + describe "Syslog::Constants.LOG_UPTO" do + it "returns a mask for the priorities up to a given argument" do + Syslog::Constants.LOG_UPTO(Syslog::LOG_ALERT).should == 3 + Syslog::Constants.LOG_UPTO(Syslog::LOG_DEBUG).should == 255 + end + end + end +end diff --git a/spec/rubyspec/library/syslog/crit_spec.rb b/spec/rubyspec/library/syslog/crit_spec.rb new file mode 100644 index 0000000000..28e3af67cc --- /dev/null +++ b/spec/rubyspec/library/syslog/crit_spec.rb @@ -0,0 +1,9 @@ +platform_is_not :windows do + require File.expand_path('../../../spec_helper', __FILE__) + require File.expand_path('../shared/log', __FILE__) + require 'syslog' + + describe "Syslog.crit" do + it_behaves_like :syslog_log, :crit + end +end diff --git a/spec/rubyspec/library/syslog/debug_spec.rb b/spec/rubyspec/library/syslog/debug_spec.rb new file mode 100644 index 0000000000..ff9fc5d97e --- /dev/null +++ b/spec/rubyspec/library/syslog/debug_spec.rb @@ -0,0 +1,9 @@ +platform_is_not :windows do + require File.expand_path('../../../spec_helper', __FILE__) + require File.expand_path('../shared/log', __FILE__) + require 'syslog' + + describe "Syslog.debug" do + it_behaves_like :syslog_log, :debug + end +end diff --git a/spec/rubyspec/library/syslog/emerg_spec.rb b/spec/rubyspec/library/syslog/emerg_spec.rb new file mode 100644 index 0000000000..15cc49be32 --- /dev/null +++ b/spec/rubyspec/library/syslog/emerg_spec.rb @@ -0,0 +1,15 @@ +platform_is_not :windows do + require File.expand_path('../../../spec_helper', __FILE__) + require File.expand_path('../shared/log', __FILE__) + require 'syslog' + + describe "Syslog.emerg" do + # Some way needs do be found to prevent this spec + # from causing output on all open terminals. If this + # is not possible, this spec may need a special guard + # that only runs when requested. + quarantine! do + it_behaves_like :syslog_log, :emerg + end + end +end diff --git a/spec/rubyspec/library/syslog/err_spec.rb b/spec/rubyspec/library/syslog/err_spec.rb new file mode 100644 index 0000000000..fdadd49e09 --- /dev/null +++ b/spec/rubyspec/library/syslog/err_spec.rb @@ -0,0 +1,9 @@ +platform_is_not :windows do + require File.expand_path('../../../spec_helper', __FILE__) + require File.expand_path('../shared/log', __FILE__) + require 'syslog' + + describe "Syslog.err" do + it_behaves_like :syslog_log, :err + end +end diff --git a/spec/rubyspec/library/syslog/facility_spec.rb b/spec/rubyspec/library/syslog/facility_spec.rb new file mode 100644 index 0000000000..02ea754b6b --- /dev/null +++ b/spec/rubyspec/library/syslog/facility_spec.rb @@ -0,0 +1,47 @@ +platform_is_not :windows do + require File.expand_path('../../../spec_helper', __FILE__) + require 'syslog' + + describe "Syslog.facility" 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 "returns the logging facility" do + Syslog.open("rubyspec", 3, Syslog::LOG_MAIL) + Syslog.facility.should == Syslog::LOG_MAIL + Syslog.close + end + + it "returns nil if the log is closed" do + Syslog.opened?.should be_false + Syslog.facility.should == nil + end + + it "defaults to LOG_USER" do + Syslog.open + Syslog.facility.should == Syslog::LOG_USER + Syslog.close + end + + it "resets after each open call" do + Syslog.open + Syslog.facility.should == Syslog::LOG_USER + + Syslog.open!("rubyspec", 3, Syslog::LOG_MAIL) + Syslog.facility.should == Syslog::LOG_MAIL + Syslog.close + + Syslog.open + Syslog.facility.should == Syslog::LOG_USER + Syslog.close + end + end + end +end diff --git a/spec/rubyspec/library/syslog/ident_spec.rb b/spec/rubyspec/library/syslog/ident_spec.rb new file mode 100644 index 0000000000..a685dfa927 --- /dev/null +++ b/spec/rubyspec/library/syslog/ident_spec.rb @@ -0,0 +1,34 @@ +platform_is_not :windows do + require File.expand_path('../../../spec_helper', __FILE__) + require 'syslog' + + describe "Syslog.ident" 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 "returns the logging identity" do + Syslog.open("rubyspec") + Syslog.ident.should == "rubyspec" + Syslog.close + end + + it "returns nil if the log is closed" do + Syslog.opened?.should == false + Syslog.ident.should == nil + end + + it "defaults to $0" do + Syslog.open + Syslog.ident.should == $0 + Syslog.close + end + end + end +end diff --git a/spec/rubyspec/library/syslog/info_spec.rb b/spec/rubyspec/library/syslog/info_spec.rb new file mode 100644 index 0000000000..88ff81994d --- /dev/null +++ b/spec/rubyspec/library/syslog/info_spec.rb @@ -0,0 +1,9 @@ +platform_is_not :windows do + require File.expand_path('../../../spec_helper', __FILE__) + require File.expand_path('../shared/log', __FILE__) + require 'syslog' + + describe "Syslog.info" do + it_behaves_like :syslog_log, :info + end +end diff --git a/spec/rubyspec/library/syslog/inspect_spec.rb b/spec/rubyspec/library/syslog/inspect_spec.rb new file mode 100644 index 0000000000..5fd7793c22 --- /dev/null +++ b/spec/rubyspec/library/syslog/inspect_spec.rb @@ -0,0 +1,38 @@ +platform_is_not :windows do + require File.expand_path('../../../spec_helper', __FILE__) + require 'syslog' + + describe "Syslog.inspect" 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 "returns a string a closed log" do + Syslog.inspect.should =~ /opened=false/ + end + + it "returns a string for an opened log" do + Syslog.open + Syslog.inspect.should =~ /opened=true.*/ + Syslog.close + end + + it "includes the ident, options, facility and mask" do + Syslog.open("rubyspec", Syslog::LOG_PID, Syslog::LOG_USER) + inspect_str = Syslog.inspect.split ", " + inspect_str[0].should =~ /opened=true/ + inspect_str[1].should == "ident=\"rubyspec\"" + inspect_str[2].should == "options=#{Syslog::LOG_PID}" + inspect_str[3].should == "facility=#{Syslog::LOG_USER}" + inspect_str[4].should == "mask=255>" + Syslog.close + end + end + end +end diff --git a/spec/rubyspec/library/syslog/instance_spec.rb b/spec/rubyspec/library/syslog/instance_spec.rb new file mode 100644 index 0000000000..60f43dbdea --- /dev/null +++ b/spec/rubyspec/library/syslog/instance_spec.rb @@ -0,0 +1,12 @@ +platform_is_not :windows do + require File.expand_path('../../../spec_helper', __FILE__) + require 'syslog' + + describe "Syslog.instance" do + platform_is_not :windows do + it "returns the module" do + Syslog.instance.should == Syslog + end + end + end +end diff --git a/spec/rubyspec/library/syslog/log_spec.rb b/spec/rubyspec/library/syslog/log_spec.rb new file mode 100644 index 0000000000..2403943cfc --- /dev/null +++ b/spec/rubyspec/library/syslog/log_spec.rb @@ -0,0 +1,55 @@ +platform_is_not :windows do + require File.expand_path('../../../spec_helper', __FILE__) + require 'syslog' + + describe "Syslog.log" do + platform_is_not :windows, :darwin, :solaris, :aix do + + before :each do + Syslog.opened?.should be_false + end + + after :each do + Syslog.opened?.should be_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) + end + + it "accepts undefined priorites" do + lambda { + 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) + end + + it "fails with TypeError on nil log messages" do + Syslog.open do |s| + lambda { s.log(1, nil) }.should raise_error(TypeError) + end + end + + it "fails if the log is closed" do + lambda { + Syslog.log(Syslog::LOG_ALERT, "test") + }.should raise_error(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) + end + end + end +end diff --git a/spec/rubyspec/library/syslog/mask_spec.rb b/spec/rubyspec/library/syslog/mask_spec.rb new file mode 100644 index 0000000000..49be56d304 --- /dev/null +++ b/spec/rubyspec/library/syslog/mask_spec.rb @@ -0,0 +1,112 @@ +platform_is_not :windows do + require File.expand_path('../../../spec_helper', __FILE__) + require 'syslog' + + describe "Syslog.mask" do + platform_is_not :windows do + + before :each do + Syslog.opened?.should be_false + end + + after :each do + Syslog.opened?.should be_false + # make sure we return the mask to the default value + Syslog.open { |s| s.mask = 255 } + end + + it "returns the log priority mask" do + Syslog.open("rubyspec") do + Syslog.mask.should == 255 + Syslog.mask = 3 + Syslog.mask.should == 3 + Syslog.mask = 255 + end + end + + it "defaults to 255" do + Syslog.open do |s| + s.mask.should == 255 + end + end + + it "returns nil if the log is closed" do + Syslog.opened?.should == false + Syslog.mask.should == nil + end + + platform_is :darwin do + it "resets if the log is reopened" do + Syslog.open + Syslog.mask.should == 255 + Syslog.mask = 64 + + Syslog.reopen("rubyspec") do + Syslog.mask.should == 255 + end + + Syslog.open do + Syslog.mask.should == 255 + end + end + end + + platform_is_not :darwin do + it "persists if the log is reopened" do + Syslog.open + Syslog.mask.should == 255 + Syslog.mask = 64 + + Syslog.reopen("rubyspec") do + Syslog.mask.should == 64 + end + + Syslog.open do + Syslog.mask.should == 64 + end + end + end + end + end + + describe "Syslog.mask=" do + platform_is_not :windows do + + before :each do + Syslog.opened?.should be_false + end + + after :each do + Syslog.opened?.should be_false + # make sure we return the mask to the default value + Syslog.open { |s| s.mask = 255 } + end + + it "sets the log priority mask" do + Syslog.open do + Syslog.mask = 64 + Syslog.mask.should == 64 + end + end + + it "raises an error if the log is closed" do + lambda { Syslog.mask = 1337 }.should raise_error(RuntimeError) + end + + it "only accepts numbers" do + Syslog.open do + + Syslog.mask = 1337 + Syslog.mask.should == 1337 + + 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) + + end + end + end + end +end diff --git a/spec/rubyspec/library/syslog/notice_spec.rb b/spec/rubyspec/library/syslog/notice_spec.rb new file mode 100644 index 0000000000..7a27e23729 --- /dev/null +++ b/spec/rubyspec/library/syslog/notice_spec.rb @@ -0,0 +1,9 @@ +platform_is_not :windows do + require File.expand_path('../../../spec_helper', __FILE__) + require File.expand_path('../shared/log', __FILE__) + require 'syslog' + + describe "Syslog.notice" do + it_behaves_like :syslog_log, :notice + end +end diff --git a/spec/rubyspec/library/syslog/open_spec.rb b/spec/rubyspec/library/syslog/open_spec.rb new file mode 100644 index 0000000000..18e7f0c80e --- /dev/null +++ b/spec/rubyspec/library/syslog/open_spec.rb @@ -0,0 +1,86 @@ +platform_is_not :windows do + require File.expand_path('../../../spec_helper', __FILE__) + require File.expand_path('../shared/reopen', __FILE__) + require 'syslog' + + describe "Syslog.open" 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 "returns the module" do + Syslog.open.should == Syslog + Syslog.close + Syslog.open("Test", 5, 9).should == Syslog + Syslog.close + end + + it "receives an identity as first argument" do + Syslog.open("rubyspec") + Syslog.ident.should == "rubyspec" + Syslog.close + end + + it "defaults the identity to $0" do + Syslog.open + Syslog.ident.should == $0 + Syslog.close + end + + it "receives the logging options as second argument" do + Syslog.open("rubyspec", Syslog::LOG_PID) + Syslog.options.should == Syslog::LOG_PID + Syslog.close + end + + it "defaults the logging options to LOG_PID | LOG_CONS" do + Syslog.open + Syslog.options.should == Syslog::LOG_PID | Syslog::LOG_CONS + Syslog.close + end + + it "receives a facility as third argument" do + Syslog.open("rubyspec", Syslog::LOG_PID, 0) + Syslog.facility.should == 0 + Syslog.close + end + + it "defaults the facility to LOG_USER" do + Syslog.open + Syslog.facility.should == Syslog::LOG_USER + Syslog.close + end + + it "receives a block and calls it with the module" do + Syslog.open("rubyspec", 3, 8) do |s| + s.should == Syslog + s.ident.should == "rubyspec" + s.options.should == 3 + s.facility.should == Syslog::LOG_USER + end + end + + it "closes the log if after it receives a block" do + Syslog.open{ } + Syslog.opened?.should be_false + end + + it "raises an error if the log is opened" do + Syslog.open + lambda { Syslog.open}.should raise_error + lambda { Syslog.close; Syslog.open }.should_not raise_error + Syslog.close + end + end + end + + describe "Syslog.open!" do + it_behaves_like :syslog_reopen, :open! + end +end diff --git a/spec/rubyspec/library/syslog/opened_spec.rb b/spec/rubyspec/library/syslog/opened_spec.rb new file mode 100644 index 0000000000..82b8ba45f7 --- /dev/null +++ b/spec/rubyspec/library/syslog/opened_spec.rb @@ -0,0 +1,38 @@ +platform_is_not :windows do + require File.expand_path('../../../spec_helper', __FILE__) + require 'syslog' + + describe "Syslog.opened?" 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 "returns true if the log is opened" do + Syslog.open + Syslog.opened?.should be_true + Syslog.close + end + + it "returns false otherwise" do + Syslog.opened?.should be_false + Syslog.open + Syslog.close + Syslog.opened?.should be_false + end + + it "works inside a block" do + Syslog.open do |s| + s.opened?.should be_true + Syslog.opened?.should be_true + end + Syslog.opened?.should be_false + end + end + end +end diff --git a/spec/rubyspec/library/syslog/options_spec.rb b/spec/rubyspec/library/syslog/options_spec.rb new file mode 100644 index 0000000000..4a3914531a --- /dev/null +++ b/spec/rubyspec/library/syslog/options_spec.rb @@ -0,0 +1,47 @@ +platform_is_not :windows do + require File.expand_path('../../../spec_helper', __FILE__) + require 'syslog' + + describe "Syslog.options" 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 "returns the logging options" do + Syslog.open("rubyspec", Syslog::LOG_PID) + Syslog.options.should == Syslog::LOG_PID + Syslog.close + end + + it "returns nil when the log is closed" do + Syslog.opened?.should be_false + Syslog.options.should == nil + end + + it "defaults to LOG_PID | LOG_CONS" do + Syslog.open + Syslog.options.should == Syslog::LOG_PID | Syslog::LOG_CONS + Syslog.close + end + + it "resets after each open call" do + Syslog.open + Syslog.options.should == Syslog::LOG_PID | Syslog::LOG_CONS + + Syslog.open!("rubyspec", Syslog::LOG_PID) + Syslog.options.should == Syslog::LOG_PID + Syslog.close + + Syslog.open + Syslog.options.should == Syslog::LOG_PID | Syslog::LOG_CONS + Syslog.close + end + end + end +end diff --git a/spec/rubyspec/library/syslog/reopen_spec.rb b/spec/rubyspec/library/syslog/reopen_spec.rb new file mode 100644 index 0000000000..de1ce2c255 --- /dev/null +++ b/spec/rubyspec/library/syslog/reopen_spec.rb @@ -0,0 +1,9 @@ +platform_is_not :windows do + require File.expand_path('../../../spec_helper', __FILE__) + require File.expand_path('../shared/reopen', __FILE__) + require 'syslog' + + describe "Syslog.reopen" do + it_behaves_like :syslog_reopen, :reopen + end +end diff --git a/spec/rubyspec/library/syslog/shared/log.rb b/spec/rubyspec/library/syslog/shared/log.rb new file mode 100644 index 0000000000..6d0d3a3c23 --- /dev/null +++ b/spec/rubyspec/library/syslog/shared/log.rb @@ -0,0 +1,40 @@ +describe :syslog_log, shared: true do + platform_is_not :windows, :darwin, :solaris, :aix do + before :each do + Syslog.opened?.should be_false + end + + after :each do + Syslog.opened?.should be_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) + 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) + 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) + end + end +end diff --git a/spec/rubyspec/library/syslog/shared/reopen.rb b/spec/rubyspec/library/syslog/shared/reopen.rb new file mode 100644 index 0000000000..fd30ab824a --- /dev/null +++ b/spec/rubyspec/library/syslog/shared/reopen.rb @@ -0,0 +1,40 @@ +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 + lambda { 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 + lambda { 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 diff --git a/spec/rubyspec/library/syslog/warning_spec.rb b/spec/rubyspec/library/syslog/warning_spec.rb new file mode 100644 index 0000000000..85fcb3a355 --- /dev/null +++ b/spec/rubyspec/library/syslog/warning_spec.rb @@ -0,0 +1,9 @@ +platform_is_not :windows do + require File.expand_path('../../../spec_helper', __FILE__) + require File.expand_path('../shared/log', __FILE__) + require 'syslog' + + describe "Syslog.warning" do + it_behaves_like :syslog_log, :warning + end +end |