File: logging_spec.rb

package info (click to toggle)
thin 1.2.4-1.1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 1,252 kB
  • ctags: 531
  • sloc: ruby: 4,529; ansic: 725; sh: 21; makefile: 16
file content (46 lines) | stat: -rw-r--r-- 905 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
require File.dirname(__FILE__) + '/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
  
  after do
    Logging.silent = true
  end
end