RSpec::LoggingHelper

Public Instance Methods

capture_log_messages( opts = {} ) click to toggle source

Capture log messages from the Logging framework and make them available via a @log_output instance variable. The @log_output supports a readline method to access the log messages.

    # File lib/rspec/logging_helper.rb, line 9
 9:     def capture_log_messages( opts = {} )
10:       from = opts.getopt(:from, 'root')
11:       to = opts.getopt(:to, '__rspec__')
12:       exclusive = opts.getopt(:exclusive, true)
13: 
14:       appender = Logging::Appenders[to] || Logging::Appenders::StringIo.new(to)
15:       logger = Logging::Logger[from]
16:       if exclusive
17:         logger.appenders = appender
18:       else
19:         logger.add_appenders(appender)
20:       end
21: 
22:       before(:all) do
23:         @log_output = Logging::Appenders[to]
24:       end
25: 
26:       before(:each) do
27:         @log_output.reset
28:       end
29:     end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.