ruby/spec/rubyspec/library/syslog/shared/log.rb
eregon 95e8c48dd3 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
2017-05-07 12:04:49 +00:00

40 lines
1.1 KiB
Ruby

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