dokkit 0.4.1 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Manifest.txt +1 -59
- data/lib/dokkit.rb +1 -1
- data/lib/dokkit/environment/basic.rb +23 -8
- data/lib/dokkit/filters.rb +1 -0
- data/lib/dokkit/filters/erb.rb +3 -3
- data/lib/dokkit/filters/haml.rb +31 -0
- data/lib/dokkit/models/simple/doc/layouts/simple.html +1 -1
- data/lib/dokkit/resource/document.rb +59 -63
- metadata +3 -61
- data/spec/dokkit/application_spec.rb +0 -141
- data/spec/dokkit/cache/cache_spec.rb +0 -87
- data/spec/dokkit/dokkit_spec.rb +0 -20
- data/spec/dokkit/environment/basic_spec.rb +0 -138
- data/spec/dokkit/environment/helpers/extmap_spec.rb +0 -52
- data/spec/dokkit/environment/helpers/fileselection_spec.rb +0 -80
- data/spec/dokkit/environment/helpers/test_data/doc/pages/document_1.ext_1 +0 -0
- data/spec/dokkit/environment/helpers/test_data/doc/pages/document_2 +0 -0
- data/spec/dokkit/environment/helpers/test_data/doc/pages/document_3.ext_3 +0 -0
- data/spec/dokkit/environment/test_data/doc/data/data +0 -0
- data/spec/dokkit/environment/test_data/doc/pages/document_1 +0 -0
- data/spec/dokkit/environment/test_data/doc/pages/document_1.yaml +0 -3
- data/spec/dokkit/environment/test_data/doc/pages/document_2 +0 -0
- data/spec/dokkit/environment/test_data/doc/pages/subdir/document_1 +0 -0
- data/spec/dokkit/factory/factory_spec.rb +0 -69
- data/spec/dokkit/filters/deplate_spec.rb +0 -47
- data/spec/dokkit/filters/erb_spec.rb +0 -26
- data/spec/dokkit/filters/maruku_spec.rb +0 -28
- data/spec/dokkit/filters/nil_spec.rb +0 -29
- data/spec/dokkit/filters/tidy_spec.rb +0 -48
- data/spec/dokkit/hash_spec.rb +0 -89
- data/spec/dokkit/logging/logger_spec.rb +0 -138
- data/spec/dokkit/logging/observers/console_spec.rb +0 -68
- data/spec/dokkit/resource/data_spec.rb +0 -32
- data/spec/dokkit/resource/document_spec.rb +0 -523
- data/spec/dokkit/resource/extensions/html_spec.rb +0 -35
- data/spec/dokkit/resource/extensions/url_spec.rb +0 -29
- data/spec/dokkit/resource/filenamehelper_spec.rb +0 -33
- data/spec/dokkit/resource/test_data/doc/configs/config_1.yaml +0 -3
- data/spec/dokkit/resource/test_data/doc/configs/config_2.yaml +0 -3
- data/spec/dokkit/resource/test_data/doc/configs/required.yaml +0 -3
- data/spec/dokkit/resource/test_data/doc/configs/subdir/document.yaml +0 -3
- data/spec/dokkit/resource/test_data/doc/layouts/container.html +0 -6
- data/spec/dokkit/resource/test_data/doc/layouts/layout.html +0 -6
- data/spec/dokkit/resource/test_data/doc/layouts/layout.latex +0 -8
- data/spec/dokkit/resource/test_data/doc/layouts/nested/nested.html +0 -4
- data/spec/dokkit/resource/test_data/doc/layouts/subdir/document.html +0 -6
- data/spec/dokkit/resource/test_data/doc/layouts/subdir/document.latex +0 -8
- data/spec/dokkit/resource/test_data/doc/pages/COMMON.yaml +0 -4
- data/spec/dokkit/resource/test_data/doc/pages/document_with_many_config.ext +0 -7
- data/spec/dokkit/resource/test_data/doc/pages/document_with_many_errors.ext +0 -12
- data/spec/dokkit/resource/test_data/doc/pages/document_with_many_targets.ext +0 -19
- data/spec/dokkit/resource/test_data/doc/pages/document_with_nested_layout.ext +0 -13
- data/spec/dokkit/resource/test_data/doc/pages/document_with_nil_target.ext +0 -5
- data/spec/dokkit/resource/test_data/doc/pages/document_with_not_defined_target.ext +0 -6
- data/spec/dokkit/resource/test_data/doc/pages/document_with_one_target.ext +0 -8
- data/spec/dokkit/resource/test_data/doc/pages/document_with_postfilter.ext +0 -10
- data/spec/dokkit/resource/test_data/doc/pages/subdir/COMMON.yaml +0 -3
- data/spec/dokkit/resource/test_data/doc/pages/subdir/document.ext +0 -8
- data/spec/dokkit/resource/test_data/doc/pages/subdir/document.yaml +0 -5
- data/spec/dokkit/tasklib/clean_spec.rb +0 -75
- data/spec/dokkit/tasklib/render_spec.rb +0 -125
- data/spec/dokkit/tasklib/test_data/doc/data/data_1 +0 -0
- data/spec/dokkit/tasklib/test_data/doc/pages/document_1 +0 -0
- data/spec/dokkit/tasklib/test_data/doc/pages/document_2 +0 -0
- data/spec/dokkit/test_data/dokkit/models/model1/doc/pages/model1 +0 -0
- data/spec/dokkit/test_data/dokkit/models/model2/doc/pages/model2 +0 -0
- data/spec/spec.opts +0 -4
- data/spec/spec_helper.rb +0 -139
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -1,69 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# File 'factory_spec.rb' created on 25 apr 2008 at 19:42:47.
|
3
|
-
# See 'dokkit.rb' or +LICENSE+ for licence information.
|
4
|
-
#
|
5
|
-
# (c) 2006, 2007, 2008 Andrea Fazzi <andrea.fazzi@alca.le.it> (and contributors).
|
6
|
-
#
|
7
|
-
# To execute this spec run:
|
8
|
-
#
|
9
|
-
# spec spec/factory_spec.rb
|
10
|
-
#
|
11
|
-
|
12
|
-
|
13
|
-
$LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(__FILE__),'../../../lib')))
|
14
|
-
|
15
|
-
require 'rubygems'
|
16
|
-
require 'spec'
|
17
|
-
require 'dokkit/factory/factory'
|
18
|
-
require 'spec/spec_helper.rb'
|
19
|
-
|
20
|
-
describe Dokkit::Factory do
|
21
|
-
include SpecHelper::Logger, SpecHelper::Cache, SpecHelper::Configuration, SpecHelper::Resource
|
22
|
-
before do
|
23
|
-
class Foo
|
24
|
-
attr_reader :arg1, :arg2
|
25
|
-
def initialize(arg1, arg2)
|
26
|
-
@arg1, @arg2 = arg1, arg2
|
27
|
-
end
|
28
|
-
end
|
29
|
-
@foo_factory_method = lambda { |arg1, arg2| Foo.new(arg1, arg2) }
|
30
|
-
end
|
31
|
-
describe ' when adding new factory method' do
|
32
|
-
before do
|
33
|
-
@factory = Dokkit::Factory.new
|
34
|
-
end
|
35
|
-
it 'should add new factory method for a particular class of objects' do
|
36
|
-
@factory.add(:foo => @foo_factory_method)
|
37
|
-
@factory.methods[:foo].should == @foo_factory_method
|
38
|
-
end
|
39
|
-
end
|
40
|
-
describe ' when client require an object instance' do
|
41
|
-
before do
|
42
|
-
@factory = Dokkit::Factory.new do |factory|
|
43
|
-
factory.add(:foo => @foo_factory_method)
|
44
|
-
end
|
45
|
-
end
|
46
|
-
it 'should construct an instance for the given class' do
|
47
|
-
instance = @factory.get(:foo, 'arg1', 'arg2')
|
48
|
-
instance.is_a?(Foo).should be_true
|
49
|
-
end
|
50
|
-
it 'should correctly process constructor arguments' do
|
51
|
-
instance = @factory.get(:foo, 'arg1', 'arg2')
|
52
|
-
instance.arg1.should == 'arg1'
|
53
|
-
instance.arg2.should == 'arg2'
|
54
|
-
end
|
55
|
-
it 'should correctly store instances' do
|
56
|
-
instance_1 = @factory.get(:foo, 'arg1', 'arg2')
|
57
|
-
instance_2 = @factory.get(:foo, 'arg3', 'arg4')
|
58
|
-
@factory.instances.should == { [:foo, 'arg1', 'arg2'] => instance_1, [:foo, 'arg3', 'arg4'] => instance_2}
|
59
|
-
end
|
60
|
-
it 'should instantiate only one object for a given class and arguments set' do
|
61
|
-
instance_1 = @factory.get(:foo, 'arg1', 'arg2')
|
62
|
-
instance_1.object_id.should == @factory.get(:foo, 'arg1', 'arg2').object_id
|
63
|
-
instance_1.object_id.should_not == @factory.get(:foo, 'arg3', 'arg4').object_id
|
64
|
-
instance_1.object_id.should == @factory.get(:foo, 'arg1', 'arg2').object_id
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
|
@@ -1,47 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# File 'filter_deplate_spec.rb' created on 18 feb 2008 at 15:22:35.
|
3
|
-
# See 'dokkit.rb' or +LICENSE+ for licence information.
|
4
|
-
#
|
5
|
-
# (c)2008 Andrea Fazzi <andrea.fazzi@alca.le.it> (and contributors).
|
6
|
-
#
|
7
|
-
# To execute this spec run:
|
8
|
-
#
|
9
|
-
# spec spec/filter_deplate_spec.rb
|
10
|
-
#
|
11
|
-
|
12
|
-
|
13
|
-
$LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(__FILE__),'../../../lib')))
|
14
|
-
|
15
|
-
require 'rubygems'
|
16
|
-
require 'spec'
|
17
|
-
require 'dokkit'
|
18
|
-
require 'dokkit/filters/deplate'
|
19
|
-
|
20
|
-
describe Dokkit::Filter::DeplateHTML do
|
21
|
-
before do
|
22
|
-
@deplate = Dokkit::Filter::DeplateHTML.new
|
23
|
-
end
|
24
|
-
it 'should transform deplate wiki text in html' do
|
25
|
-
@deplate.filter('* Header').should =~ /\<h1.*\>1 Header\<\/h1\>/
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
describe Dokkit::Filter::DeplateLatex do
|
30
|
-
before do
|
31
|
-
@deplate = Dokkit::Filter::DeplateLatex.new
|
32
|
-
end
|
33
|
-
it 'should transform deplate wiki text in tex' do
|
34
|
-
@deplate.filter('* Header').should =~ /\\section\{Header\}/
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
describe Dokkit::Filter::DeplateText do
|
39
|
-
before do
|
40
|
-
@deplate = Dokkit::Filter::DeplateText.new
|
41
|
-
end
|
42
|
-
it 'should transform deplate wiki text in plain text' do
|
43
|
-
@deplate.filter('* Header').should =~ /\n1 Header\n=+$/
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
|
@@ -1,26 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# File 'erb_spec.rb' created on 23 lug 2008 at 15:38:04.
|
3
|
-
# See 'dokkit.rb' or +LICENSE+ for licence information.
|
4
|
-
#
|
5
|
-
# (c)2006-2008 Andrea Fazzi <andrea.fazzi@alca.le.it> (and contributors).
|
6
|
-
# #
|
7
|
-
# To execute this spec run:
|
8
|
-
#
|
9
|
-
# spec spec/dokkit/filters/erb_spec.rb
|
10
|
-
#
|
11
|
-
|
12
|
-
$LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(__FILE__),'../../../lib')))
|
13
|
-
|
14
|
-
require 'rubygems'
|
15
|
-
require 'spec'
|
16
|
-
require 'dokkit'
|
17
|
-
require 'dokkit/filters/erb'
|
18
|
-
|
19
|
-
describe Dokkit::Filter::ERB do
|
20
|
-
before do
|
21
|
-
@erb = Dokkit::Filter::ERB.new(binding)
|
22
|
-
end
|
23
|
-
it 'should compile an erb template' do
|
24
|
-
@erb.filter('<%= "process this" %>').should == "process this"
|
25
|
-
end
|
26
|
-
end
|
@@ -1,28 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# File 'filter_maruku_spec.rb' created on 15 feb 2008 at 22:52:14.
|
3
|
-
# See 'dokkit.rb' or +LICENSE+ for licence information.
|
4
|
-
#
|
5
|
-
# (c)2008 Andrea Fazzi <andrea.fazzi@alca.le.it> (and contributors).
|
6
|
-
#
|
7
|
-
# To execute this spec run:
|
8
|
-
#
|
9
|
-
# spec spec/filter_maruku_spec.rb
|
10
|
-
#
|
11
|
-
|
12
|
-
|
13
|
-
$LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(__FILE__),'../../../lib')))
|
14
|
-
|
15
|
-
require 'rubygems'
|
16
|
-
require 'spec'
|
17
|
-
require 'dokkit'
|
18
|
-
require 'dokkit/filters/maruku'
|
19
|
-
|
20
|
-
describe Dokkit::Filter::MarukuHTML do
|
21
|
-
before do
|
22
|
-
@maruku = Dokkit::Filter::MarukuHTML.new
|
23
|
-
end
|
24
|
-
it 'should transform markdown text in html' do
|
25
|
-
@result = @maruku.filter('# Header').should =~ /\<h1.*\>Header\<\/h1\>/
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
@@ -1,29 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# File 'filter_nil_spec.rb' created on 18 mar 2008 at 12:39:00.
|
3
|
-
# See 'dokkit.rb' or +LICENSE+ for licence information.
|
4
|
-
#
|
5
|
-
# (c)2008 Andrea Fazzi <andrea.fazzi@alca.le.it> (and contributors).
|
6
|
-
#
|
7
|
-
# To execute this spec run:
|
8
|
-
#
|
9
|
-
# spec spec/filter_nil_spec.rb
|
10
|
-
#
|
11
|
-
|
12
|
-
|
13
|
-
$LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(__FILE__),'../../../lib')))
|
14
|
-
|
15
|
-
require 'rubygems'
|
16
|
-
require 'spec'
|
17
|
-
require 'dokkit'
|
18
|
-
require 'dokkit/filters/nil'
|
19
|
-
|
20
|
-
describe Dokkit::Filter::Nil do
|
21
|
-
before do
|
22
|
-
@nil = Dokkit::Filter::Nil.new
|
23
|
-
end
|
24
|
-
it 'should not transform source file' do
|
25
|
-
@result = @nil.filter('Do *not* transform this text.').should == 'Do *not* transform this text.'
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
|
@@ -1,48 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# File 'tidy_spec.rb' created on 27 lug 2008 at 14:30:55.
|
3
|
-
# See 'dokkit.rb' or +LICENSE+ for licence information.
|
4
|
-
#
|
5
|
-
# (c)2006-2008 Andrea Fazzi <andrea.fazzi@alca.le.it> (and contributors).
|
6
|
-
#
|
7
|
-
|
8
|
-
$LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(__FILE__),'../../../lib')))
|
9
|
-
|
10
|
-
require 'rubygems'
|
11
|
-
require 'spec'
|
12
|
-
require 'dokkit'
|
13
|
-
require 'dokkit/filters/tidy'
|
14
|
-
|
15
|
-
INPUT = <<EOI
|
16
|
-
<html>
|
17
|
-
<body>
|
18
|
-
<p>content</p>
|
19
|
-
</body>
|
20
|
-
</html>
|
21
|
-
EOI
|
22
|
-
|
23
|
-
OUTPUT = <<EOO
|
24
|
-
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2//EN">
|
25
|
-
|
26
|
-
<html>
|
27
|
-
<head>
|
28
|
-
<meta name="generator" content=
|
29
|
-
"HTML Tidy for Linux/x86 (vers 1 September 2005), see www.w3.org">
|
30
|
-
|
31
|
-
<title></title>
|
32
|
-
</head>
|
33
|
-
|
34
|
-
<body>
|
35
|
-
<p>content</p>
|
36
|
-
</body>
|
37
|
-
</html>
|
38
|
-
EOO
|
39
|
-
|
40
|
-
describe Dokkit::Filter::Tidy do
|
41
|
-
before do
|
42
|
-
@tidy = Dokkit::Filter::Tidy.new
|
43
|
-
end
|
44
|
-
it 'should compile an erb template' do
|
45
|
-
@tidy.filter(INPUT).should == OUTPUT
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
data/spec/dokkit/hash_spec.rb
DELETED
@@ -1,89 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# File 'recursivemerge_spec.rb' created on 09 feb 2008 at 19:08:20.
|
3
|
-
# See 'dokkit.rb' or +LICENSE+ for licence information.
|
4
|
-
#
|
5
|
-
# (c)2006-2008 Andrea Fazzi <andrea.fazzi@alca.le.it> (and contributors).
|
6
|
-
#
|
7
|
-
|
8
|
-
$LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(__FILE__),'../../lib')))
|
9
|
-
|
10
|
-
require 'rubygems'
|
11
|
-
require 'spec'
|
12
|
-
require 'dokkit/hash'
|
13
|
-
|
14
|
-
describe Hash do
|
15
|
-
describe 'when two hash with depth 0 are merged' do
|
16
|
-
before do
|
17
|
-
@h1 = { :a => "a", :b => "b" }
|
18
|
-
@h2 = { :c => "c" }
|
19
|
-
end
|
20
|
-
it 'should return a new hash with :a, :b, :c keys' do
|
21
|
-
@h1.recursive_merge(@h2).should == { :a => "a", :b => "b", :c => "c"}
|
22
|
-
end
|
23
|
-
end
|
24
|
-
describe 'when two hash with depth 1 are merged' do
|
25
|
-
before do
|
26
|
-
@h1 = { :depth1 => { :a => "a", :b => "b" }, :b => "b" }
|
27
|
-
@h2 = { :depth1 => { :a => "a'", :c => "c" }, :b => "b'" }
|
28
|
-
end
|
29
|
-
it 'should return a new hash merging depth 1 values,' do
|
30
|
-
@h1.recursive_merge(@h2).should == { :depth1 => { :a => "a'", :b => "b", :c => "c"}, :b => "b'" }
|
31
|
-
end
|
32
|
-
end
|
33
|
-
describe 'when two hash with depth 2 and depth 1 are merged' do
|
34
|
-
before do
|
35
|
-
@h1 = { :depth1 => { :depth2 => { :a => "a", :b => "b" } }, :b => "b" }
|
36
|
-
@h2 = { :depth1 => { :a => "a'", :b => "b'", :c => "c"}, :b => "b" }
|
37
|
-
end
|
38
|
-
it 'should return a new hash merging the depth 1 values adding the depth 2 key' do
|
39
|
-
@h1.recursive_merge(@h2).should == { :depth1 => {:depth2 => { :a => "a", :b => "b" }, :a => "a'", :b => "b'", :c => "c"}, :b => "b" }
|
40
|
-
end
|
41
|
-
end
|
42
|
-
describe 'when a block is passed to recursive_merge' do
|
43
|
-
it 'should use the block to store values' do
|
44
|
-
{ :a => 'a' }.recursive_merge({ :a => ['b', 'c'] }) do |key, value, other_value|
|
45
|
-
if(value.class == String && other_value.class == Array)
|
46
|
-
value.to_a.concat(other_value)
|
47
|
-
else
|
48
|
-
store(key, other_value)
|
49
|
-
end
|
50
|
-
end.should == { :a => ['a', 'b', 'c'] }
|
51
|
-
end
|
52
|
-
end
|
53
|
-
describe 'when a string and an array are merged' do
|
54
|
-
before do
|
55
|
-
@h1 = { :a => 'a' }
|
56
|
-
@h2 = { :a => ['b', 'c'] }
|
57
|
-
end
|
58
|
-
it 'should concatenate the string and the array' do
|
59
|
-
@h1.recursive_merge(@h2).should == { :a => ['a', 'b', 'c'] }
|
60
|
-
@h2.recursive_merge(@h1).should == { :a => ['b', 'c', 'a'] }
|
61
|
-
end
|
62
|
-
end
|
63
|
-
describe 'when two array are merged' do
|
64
|
-
before do
|
65
|
-
@h1 = { :a => { :b => ['a', 'b'] } }
|
66
|
-
@h2 = { :a => { :b => ['c', 'd'] } }
|
67
|
-
end
|
68
|
-
it 'should concatenate the arrays' do
|
69
|
-
@h1.recursive_merge(@h2).should == { :a => { :b => ['a', 'b', 'c', 'd'] } }
|
70
|
-
end
|
71
|
-
end
|
72
|
-
describe 'when a :clear key is encountered' do
|
73
|
-
it 'should stop merging string and string' do
|
74
|
-
{ :a => 'a', :b => 'b' }.recursive_merge({ :a => 'clear', :c => 'c' }).should == { :a => nil, :b => 'b', :c => 'c' }
|
75
|
-
end
|
76
|
-
it 'should stop merging symbol and string' do
|
77
|
-
{ :a => :a, :b => 'b' }.recursive_merge({ :a => 'clear', :c => 'c' }).should == { :a => nil, :b => 'b', :c => 'c' }
|
78
|
-
end
|
79
|
-
it 'should stop merging arrays' do
|
80
|
-
{ :a => ['a', 'b'], :b => 'b' }.recursive_merge({ :a => ['a', 'clear'], :c => 'c' }).should == { :a => ['a'], :b => 'b', :c => 'c' }
|
81
|
-
end
|
82
|
-
it 'should stop merging array and string' do
|
83
|
-
{ :a => ['a', 'b'], :b => 'b' }.recursive_merge({ :a => 'clear', :c => 'c' }).should == { :a => nil, :b => 'b', :c => 'c' }
|
84
|
-
end
|
85
|
-
it 'should stop merging string and array' do
|
86
|
-
{ :a => 'a', :b => 'b' }.recursive_merge({ :a => ['clear', 'b'], :c => 'c' }).should == { :a => ['b'], :b => 'b', :c => 'c' }
|
87
|
-
end
|
88
|
-
end
|
89
|
-
end
|
@@ -1,138 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# File 'logger_spec.rb' created on 23 feb 2008 at 15:47:50.
|
3
|
-
# See 'dokkit.rb' or +LICENSE+ for licence information.
|
4
|
-
#
|
5
|
-
# (c)2008 Andrea Fazzi <andrea.fazzi@alca.le.it> (and contributors).
|
6
|
-
#
|
7
|
-
# To execute this spec run:
|
8
|
-
#
|
9
|
-
# spec spec/logger_spec.rb
|
10
|
-
#
|
11
|
-
|
12
|
-
$LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(__FILE__),'../../../lib')))
|
13
|
-
|
14
|
-
require 'rubygems'
|
15
|
-
require 'spec'
|
16
|
-
require 'dokkit'
|
17
|
-
require 'dokkit/logging/logger'
|
18
|
-
|
19
|
-
describe Dokkit::Logging::Logger do
|
20
|
-
before do
|
21
|
-
@logger = Dokkit::Logging::Logger.new
|
22
|
-
@observer = mock('observer')
|
23
|
-
end
|
24
|
-
it 'should be set with INFO log level by default' do
|
25
|
-
@logger.level.should == Dokkit::Logging::INFO
|
26
|
-
end
|
27
|
-
it 'should fix log level if out of range' do
|
28
|
-
@logger.level = 5
|
29
|
-
@logger.level.should == Dokkit::Logging::DEBUG
|
30
|
-
@logger.level = -2
|
31
|
-
@logger.level.should == Dokkit::Logging::OFF
|
32
|
-
end
|
33
|
-
it 'should add observer to the observers list' do
|
34
|
-
@logger.attach(@observer).should == @observer
|
35
|
-
@logger.observers.should == [@observer]
|
36
|
-
end
|
37
|
-
it 'should remove the given observer from observers list' do
|
38
|
-
@logger.attach(@observer)
|
39
|
-
@logger.detach(@observer).should == @observer
|
40
|
-
@logger.observers.should be_empty
|
41
|
-
end
|
42
|
-
it 'should send updated messages to the observers' do
|
43
|
-
@observer.should_receive(:update)
|
44
|
-
@logger.attach(@observer)
|
45
|
-
@logger.notify
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
describe Dokkit::Logging::Logger, ' when log level changes' do
|
50
|
-
before do
|
51
|
-
@logger = Dokkit::Logging::Logger.new
|
52
|
-
end
|
53
|
-
describe ' to OFF' do
|
54
|
-
before do
|
55
|
-
@logger.level = Dokkit::Logging::OFF
|
56
|
-
end
|
57
|
-
it 'should disable logging' do
|
58
|
-
@logger.error('This is an error message.').should be_nil
|
59
|
-
@logger.warn('This is a warning message').should be_nil
|
60
|
-
@logger.info('This is an info message').should be_nil
|
61
|
-
@logger.debug('This is a debug message').should be_nil
|
62
|
-
end
|
63
|
-
end
|
64
|
-
describe ' to ERROR' do
|
65
|
-
before do
|
66
|
-
@logger.level = Dokkit::Logging::ERROR
|
67
|
-
end
|
68
|
-
it 'should send error messages only' do
|
69
|
-
@logger.error('This is an error message.').should == {
|
70
|
-
:text => 'This is an error message.',
|
71
|
-
:level => Dokkit::Logging::ERROR
|
72
|
-
}
|
73
|
-
@logger.warn('This is a warning message').should be_nil
|
74
|
-
@logger.info('This is an info message').should be_nil
|
75
|
-
@logger.debug('This is a debug message').should be_nil
|
76
|
-
end
|
77
|
-
end
|
78
|
-
describe ' to WARNING' do
|
79
|
-
before do
|
80
|
-
@logger.level = Dokkit::Logging::WARNING
|
81
|
-
end
|
82
|
-
it 'should send error and warning messages only' do
|
83
|
-
@logger.error('This is an error message.').should == {
|
84
|
-
:text => 'This is an error message.',
|
85
|
-
:level => Dokkit::Logging::ERROR
|
86
|
-
}
|
87
|
-
@logger.warn('This is a warning message.').should == {
|
88
|
-
:text => 'This is a warning message.',
|
89
|
-
:level => Dokkit::Logging::WARNING
|
90
|
-
}
|
91
|
-
@logger.info('This is an info message').should be_nil
|
92
|
-
@logger.debug('This is a debug message').should be_nil
|
93
|
-
end
|
94
|
-
end
|
95
|
-
describe ' to INFO' do
|
96
|
-
before do
|
97
|
-
@logger.level = Dokkit::Logging::INFO
|
98
|
-
end
|
99
|
-
it 'should send error, warning and info messages only' do
|
100
|
-
@logger.error('This is an error message.').should == {
|
101
|
-
:text => 'This is an error message.',
|
102
|
-
:level => Dokkit::Logging::ERROR
|
103
|
-
}
|
104
|
-
@logger.warn('This is a warning message.').should == {
|
105
|
-
:text => 'This is a warning message.',
|
106
|
-
:level => Dokkit::Logging::WARNING
|
107
|
-
}
|
108
|
-
@logger.info('This is an info message.').should == {
|
109
|
-
:text => 'This is an info message.',
|
110
|
-
:level => Dokkit::Logging::INFO
|
111
|
-
}
|
112
|
-
@logger.debug('This is a debug message').should be_nil
|
113
|
-
end
|
114
|
-
end
|
115
|
-
describe ' to DEBUG' do
|
116
|
-
before do
|
117
|
-
@logger.level = Dokkit::Logging::DEBUG
|
118
|
-
end
|
119
|
-
it 'should send all messages' do
|
120
|
-
@logger.error('This is an error message.').should == {
|
121
|
-
:text => 'This is an error message.',
|
122
|
-
:level => Dokkit::Logging::ERROR
|
123
|
-
}
|
124
|
-
@logger.warn('This is a warning message.').should == {
|
125
|
-
:text => 'This is a warning message.',
|
126
|
-
:level => Dokkit::Logging::WARNING
|
127
|
-
}
|
128
|
-
@logger.info('This is an info message.').should == {
|
129
|
-
:text => 'This is an info message.',
|
130
|
-
:level => Dokkit::Logging::INFO
|
131
|
-
}
|
132
|
-
@logger.debug('This is a debug message.').should == {
|
133
|
-
:text => 'This is a debug message.',
|
134
|
-
:level => Dokkit::Logging::DEBUG
|
135
|
-
}
|
136
|
-
end
|
137
|
-
end
|
138
|
-
end
|