Sha256: c0d4f1d6fa8728c4cc41aed0d9292cb05d7f01c38ee3a4d202a41ea20799e34b

Contents?: true

Size: 1.05 KB

Versions: 48

Compression:

Stored size: 1.05 KB

Contents

require 'spec_helper'

class TestLogging
  include Logging
end

describe Logging do
  before do
    Logging.silent = false
    @object = TestLogging.new
  end
  
  it "should output debug when set to true" do
    Logging.debug = true
    @object.should_receive(:puts)
    @object.debug 'hi'
  end

  it "should output trace when set to true" do
    Logging.trace = true
    @object.should_receive(:puts)
    @object.trace 'hi'
  end

  it "should not output when silenced" do
    Logging.silent = true
    @object.should_not_receive(:puts)
    @object.log 'hi'
  end
  
  it "should not output when silenced as instance method" do
    @object.silent = true
    
    @object.should_not_receive(:puts)
    @object.log 'hi'
  end
  
  it "should be usable as module functions" do
    Logging.silent = true
    Logging.log "hi"
  end

  it "should print errors to STDERR" do
    error = mock(:error, :backtrace => Array("PC LOAD LETTER"))
    STDERR.should_receive(:print).with(/PC LOAD LETTER/)
    @object.log_error(error)
  end
  
  after do
    Logging.silent = true
  end
end

Version data entries

48 entries across 48 versions & 2 rubygems

Version Path
classiccms-0.7.5 vendor/bundle/gems/thin-1.3.1/spec/logging_spec.rb
classiccms-0.7.4 vendor/bundle/gems/thin-1.3.1/spec/logging_spec.rb
classiccms-0.7.3 vendor/bundle/gems/thin-1.3.1/spec/logging_spec.rb
classiccms-0.7.2 vendor/bundle/gems/thin-1.3.1/spec/logging_spec.rb
classiccms-0.7.1 vendor/bundle/gems/thin-1.3.1/spec/logging_spec.rb
classiccms-0.7.0 vendor/bundle/gems/thin-1.3.1/spec/logging_spec.rb
classiccms-0.6.9 vendor/bundle/gems/thin-1.3.1/spec/logging_spec.rb
classiccms-0.6.8 vendor/bundle/gems/thin-1.3.1/spec/logging_spec.rb
classiccms-0.6.7 vendor/bundle/gems/thin-1.3.1/spec/logging_spec.rb
classiccms-0.6.6 vendor/bundle/gems/thin-1.3.1/spec/logging_spec.rb
classiccms-0.6.5 vendor/bundle/gems/thin-1.3.1/spec/logging_spec.rb
classiccms-0.6.4 vendor/bundle/gems/thin-1.3.1/spec/logging_spec.rb
classiccms-0.6.3 vendor/bundle/gems/thin-1.3.1/spec/logging_spec.rb
classiccms-0.6.2 vendor/bundle/gems/thin-1.3.1/spec/logging_spec.rb
classiccms-0.6.1 vendor/bundle/gems/thin-1.3.1/spec/logging_spec.rb
classiccms-0.6.0 vendor/bundle/gems/thin-1.3.1/spec/logging_spec.rb
classiccms-0.5.17 vendor/bundle/gems/thin-1.3.1/spec/logging_spec.rb
classiccms-0.5.16 vendor/bundle/gems/thin-1.3.1/spec/logging_spec.rb
classiccms-0.5.15 vendor/bundle/gems/thin-1.3.1/spec/logging_spec.rb
classiccms-0.5.14 vendor/bundle/gems/thin-1.3.1/spec/logging_spec.rb