Pistos-ramaze 2008.12 → 2009.01

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7,67 +7,70 @@ require 'ramaze/log/syslog'
7
7
 
8
8
  describe 'Syslog' do
9
9
 
10
- # close the syslog, if it was open for some reason before we
11
- # start a test.
12
- before do
13
- if ( Syslog.opened? )
14
- ::Syslog.close
15
- end
16
- end
10
+ # close the syslog, if it was open for some reason before we
11
+ # start a test.
12
+ before do
13
+ if ( Syslog.opened? )
14
+ ::Syslog.close
15
+ end
16
+ end
17
17
 
18
- it 'should default initialize correctly' do
19
- syslog = Ramaze::Logger::Syslog.new
20
- ::Syslog.opened?.should == true
21
- ::Syslog.ident.should == $0
22
- ::Syslog.options.should == ( ::Syslog::LOG_PID | ::Syslog::LOG_CONS )
23
- ::Syslog.facility.should == ::Syslog::LOG_USER
24
- end
18
+ it 'should default initialize correctly' do
19
+ syslog = Ramaze::Logger::Syslog.new
20
+ ::Syslog.opened?.should == true
21
+ ::Syslog.ident.should == $0
22
+ ::Syslog.options.should == ( ::Syslog::LOG_PID | ::Syslog::LOG_CONS )
23
+ ::Syslog.facility.should == ::Syslog::LOG_USER
24
+ end
25
25
 
26
- it 'should handle non default initialization' do
27
- syslog = Ramaze::Logger::Syslog.new( 'ramaze_syslog_test',
28
- ::Syslog::LOG_NDELAY | ::Syslog::LOG_NOWAIT,
29
- ::Syslog::LOG_DAEMON )
30
- ::Syslog.opened?.should == true
31
- ::Syslog.ident.should == 'ramaze_syslog_test'
32
- ::Syslog.options.should == ( ::Syslog::LOG_NDELAY | ::Syslog::LOG_NOWAIT )
33
- ::Syslog.facility.should == ::Syslog::LOG_DAEMON
34
- end
26
+ it 'should handle non default initialization' do
27
+ syslog = Ramaze::Logger::Syslog.new(
28
+ 'ramaze_syslog_test', ::Syslog::LOG_NDELAY | ::Syslog::LOG_NOWAIT,
29
+ ::Syslog::LOG_DAEMON
30
+ )
31
+ ::Syslog.opened?.should == true
32
+ ::Syslog.ident.should == 'ramaze_syslog_test'
33
+ ::Syslog.options.should == ( ::Syslog::LOG_NDELAY | ::Syslog::LOG_NOWAIT )
34
+ ::Syslog.facility.should == ::Syslog::LOG_DAEMON
35
+ end
35
36
 
36
- # We test the actual logging using a trick found in te test code of the
37
- # syslog module. We create a pipe, fork a child, reroute the childs
38
- # stderr to the pipe. Then we open the logging using LOG_PERROR, so all
39
- # log messages are written to stderror. In the parent we read the messages
40
- # from the pipe and compare them to what we expected.
41
- def test_log_msg( type, priority, msg )
42
- logpipe = IO::pipe
43
- child = fork {
44
- logpipe[0].close
45
- STDERR.reopen(logpipe[1])
46
- syslog = Ramaze::Logger::Syslog.new( 'ramaze_syslog_test',
47
- ::Syslog::LOG_PID | ::Syslog::LOG_NDELAY | ::Syslog::LOG_PERROR,
48
- ::Syslog::LOG_USER )
49
- syslog.send priority, msg
50
- Process.exit!( 0 )
51
- }
52
- logpipe[1].close
53
- Process.waitpid(child)
37
+ # We test the actual logging using a trick found in te test code of the
38
+ # syslog module. We create a pipe, fork a child, reroute the childs
39
+ # stderr to the pipe. Then we open the logging using LOG_PERROR, so all
40
+ # log messages are written to stderror. In the parent we read the messages
41
+ # from the pipe and compare them to what we expected.
42
+ def test_log_msg( type, priority, msg )
43
+ logpipe = IO::pipe
44
+ child = fork {
45
+ logpipe[0].close
46
+ STDERR.reopen(logpipe[1])
47
+ syslog = Ramaze::Logger::Syslog.new(
48
+ 'ramaze_syslog_test',
49
+ ::Syslog::LOG_PID | ::Syslog::LOG_NDELAY | ::Syslog::LOG_PERROR,
50
+ ::Syslog::LOG_USER
51
+ )
52
+ syslog.send priority, msg
53
+ Process.exit!( 0 )
54
+ }
55
+ logpipe[1].close
56
+ Process.waitpid(child)
54
57
 
55
- logpipe[0].gets.should == "ramaze_syslog_test[#{child}]: #{msg}\n"
56
- end
57
-
58
- it 'should handle debug' do
59
- test_log_msg :direct, :debug, "Hello Debug World"
60
- end
61
- it 'should handle dev' do
62
- test_log_msg :direct, :dev, "Hello Dev World"
63
- end
64
- it 'should handle info' do
65
- test_log_msg :direct, :info, 'Hello Info World!'
66
- end
67
- it 'should handle warn' do
68
- test_log_msg :direct, :warn, 'Hello Warn World!'
69
- end
70
- it 'should handle error' do
71
- test_log_msg :direct, :error, 'Hello Error World!'
72
- end
58
+ logpipe[0].gets.should == "ramaze_syslog_test[#{child}]: #{msg}\n"
59
+ end
60
+
61
+ it 'should handle debug' do
62
+ test_log_msg :direct, :debug, "Hello Debug World"
63
+ end
64
+ it 'should handle dev' do
65
+ test_log_msg :direct, :dev, "Hello Dev World"
66
+ end
67
+ it 'should handle info' do
68
+ test_log_msg :direct, :info, 'Hello Info World!'
69
+ end
70
+ it 'should handle warn' do
71
+ test_log_msg :direct, :warn, 'Hello Warn World!'
72
+ end
73
+ it 'should handle error' do
74
+ test_log_msg :direct, :error, 'Hello Error World!'
75
+ end
73
76
  end