spec/syslogger_spec.rb in syslogger-1.4.2 vs spec/syslogger_spec.rb in syslogger-1.5.0
- old
+ new
@@ -101,10 +101,28 @@
Syslog.should_receive(:open).with("progname", Syslog::LOG_PID, Syslog::LOG_USER).and_yield(syslog=mock("syslog", :mask= => true))
syslog.should_receive(:log).with(Syslog::LOG_INFO, "message")
@logger.add(Logger::INFO, "message", "progname") { "my message" }
end
+ it "should use the default progname when message is passed in progname" do
+ Syslog.should_receive(:open).
+ with("my_app", Syslog::LOG_PID, Syslog::LOG_USER).
+ and_yield(syslog = mock("syslog", :mask= => true))
+
+ syslog.should_receive(:log).with(Syslog::LOG_INFO, "message")
+ @logger.add(Logger::INFO, nil, "message")
+ end
+
+ it "should use the given progname if message is passed in block" do
+ Syslog.should_receive(:open).
+ with("progname", Syslog::LOG_PID, Syslog::LOG_USER).
+ and_yield(syslog = mock("syslog", :mask= => true))
+
+ syslog.should_receive(:log).with(Syslog::LOG_INFO, "message")
+ @logger.add(Logger::INFO, nil, "progname") { "message" }
+ end
+
it "should substitute '%' for '%%' before adding the :message" do
Syslog.stub(:open).and_yield(syslog=mock("syslog", :mask= => true))
syslog.should_receive(:log).with(Syslog::LOG_INFO, "%%me%%ssage%%")
@logger.add(Logger::INFO, "%me%ssage%")
end
@@ -117,20 +135,20 @@
it "should not raise exception if asked to log with a nil message and body" do
Syslog.should_receive(:open).
with("my_app", Syslog::LOG_PID, Syslog::LOG_USER).
and_yield(syslog=mock("syslog", :mask= => true))
- syslog.should_receive(:log).with(Syslog::LOG_INFO, "my_app")
+ syslog.should_receive(:log).with(Syslog::LOG_INFO, "")
lambda {
@logger.add(Logger::INFO, nil)
}.should_not raise_error
end
- it "should use given progname as the message if the message and block are nil" do
+ it "should send an empty string if the message and block are nil" do
Syslog.should_receive(:open).
with("my_app", Syslog::LOG_PID, Syslog::LOG_USER).
and_yield(syslog=mock("syslog", :mask= => true))
- syslog.should_receive(:log).with(Syslog::LOG_INFO, "my_app")
+ syslog.should_receive(:log).with(Syslog::LOG_INFO, "")
@logger.add(Logger::INFO, nil)
end
it "should split string over the max octet size" do
@logger.max_octets = 480