26
26
describe Puppet::Util::Log.desttypes[:file] do
27
include PuppetSpec::Files
28
30
File.stubs(:open) # prevent actually creating the file
31
File.stubs(:chown) # prevent chown on non existing file from failing
29
32
@class = Puppet::Util::Log.desttypes[:file]
32
it "should default to automatically flush log output" do
33
@class.new('/tmp/log').autoflush.should == true
35
it "should default to autoflush false" do
36
@class.new(tmpfile('log')).autoflush.should == true
36
39
describe "when matching" do
108
111
describe Puppet::Util::Log.desttypes[:console] do
109
describe "when color is available" do
111
subject.stubs(:console_has_color?).returns(true)
114
it "should support color output" do
115
Puppet[:color] = true
116
subject.colorize(:red, 'version').should == "\e[0;31mversion\e[0m"
119
it "should withhold color output when not appropriate" do
120
Puppet[:color] = false
121
subject.colorize(:red, 'version').should == "version"
124
it "should handle multiple overlapping colors in a stack-like way" do
125
Puppet[:color] = true
126
vstring = subject.colorize(:red, 'version')
127
subject.colorize(:green, "(#{vstring})").should == "\e[0;32m(\e[0;31mversion\e[0;32m)\e[0m"
130
it "should handle resets in a stack-like way" do
131
Puppet[:color] = true
132
vstring = subject.colorize(:reset, 'version')
133
subject.colorize(:green, "(#{vstring})").should == "\e[0;32m(\e[mversion\e[0;32m)\e[0m"
138
describe Puppet::Util::Log.desttypes[:telly_prototype_console] do
139
describe "when color is available" do
141
subject.stubs(:console_has_color?).returns(true)
144
it "should support color output" do
145
Puppet[:color] = true
146
subject.colorize(:red, 'version').should == "\e[0;31mversion\e[0m"
149
it "should withhold color output when not appropriate" do
150
Puppet[:color] = false
151
subject.colorize(:red, 'version').should == "version"
154
it "should handle multiple overlapping colors in a stack-like way" do
155
Puppet[:color] = true
156
vstring = subject.colorize(:red, 'version')
157
subject.colorize(:green, "(#{vstring})").should == "\e[0;32m(\e[0;31mversion\e[0;32m)\e[0m"
160
it "should handle resets in a stack-like way" do
161
Puppet[:color] = true
162
vstring = subject.colorize(:reset, 'version')
163
subject.colorize(:green, "(#{vstring})").should == "\e[0;32m(\e[mversion\e[0;32m)\e[0m"
112
let (:klass) { Puppet::Util::Log.desttypes[:console] }
114
describe "when color is available" do
116
subject.stubs(:console_has_color?).returns(true)
119
it "should support color output" do
120
Puppet[:color] = true
121
subject.colorize(:red, 'version').should == "\e[0;31mversion\e[0m"
124
it "should withhold color output when not appropriate" do
125
Puppet[:color] = false
126
subject.colorize(:red, 'version').should == "version"
129
it "should handle multiple overlapping colors in a stack-like way" do
130
Puppet[:color] = true
131
vstring = subject.colorize(:red, 'version')
132
subject.colorize(:green, "(#{vstring})").should == "\e[0;32m(\e[0;31mversion\e[0;32m)\e[0m"
135
it "should handle resets in a stack-like way" do
136
Puppet[:color] = true
137
vstring = subject.colorize(:reset, 'version')
138
subject.colorize(:green, "(#{vstring})").should == "\e[0;32m(\e[mversion\e[0;32m)\e[0m"
141
it "should include the log message's source/context in the output when available" do
142
Puppet[:color] = false
143
$stdout.expects(:puts).with("Info: a hitchhiker: don't panic")
145
msg = Puppet::Util::Log.new(:level => :info, :message => "don't panic", :source => "a hitchhiker")