Loggability::SpecHelpers

Some helper functions for testing. Usage:

RSpec.configure do |c|
    c.include( Loggability::SpecHelpers )
end

describe MyClass do
    before( :all ) { setup_logging }
    after( :all ) { reset_logging }

    # ...

end

Public Instance Methods

reset_logging() click to toggle source

Reset the logging subsystem to its default state.

# File lib/loggability/spechelpers.rb, line 23
def reset_logging
        Loggability.formatter = nil
        Loggability.output_to( $stderr )
        Loggability.level = :fatal
end
setup_logging( level=:fatal ) click to toggle source

Alter the output of the default log formatter to be pretty in SpecMate output if HTML_LOGGING is set or TM_FILENAME is set to something containing _spec.rb.

# File lib/loggability/spechelpers.rb, line 32
def setup_logging( level=:fatal )

        # Only do this when executing from a spec in TextMate
        if ENV['HTML_LOGGING'] || (ENV['TM_FILENAME'] && ENV['TM_FILENAME'] =~ /_spec\.rb/)
                logarray = []
                Thread.current['logger-output'] = logarray
                Loggability.output_to( logarray )
                Loggability.format_as( :html )
                Loggability.level = :debug
        else
                Loggability.level = level
        end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.