dokkit 0.4.1 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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
@@ -1,68 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# File 'consolelog_spec.rb' created on 23 feb 2008 at 16:40:31.
|
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/consolelog_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/logging/observers/console'
|
19
|
-
require 'spec/spec_helper.rb'
|
20
|
-
|
21
|
-
describe Dokkit::Logging::Observer::Console, ' when initialized' do
|
22
|
-
it 'should reference to a logger instance and attach to it' do
|
23
|
-
@logger = mock('logger')
|
24
|
-
@logger.should_receive(:attach)
|
25
|
-
@consolelog = Dokkit::Logging::Observer::Console.new(@logger)
|
26
|
-
@consolelog.logger.should_not be_nil
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
describe Dokkit::Logging::Observer::Console, ' when logger notifies' do
|
31
|
-
include SpecHelper::CaptureOutput
|
32
|
-
before do
|
33
|
-
@logger = mock('logger')
|
34
|
-
@logger.stub!(:attach)
|
35
|
-
@consolelog = Dokkit::Logging::Observer::Console.new(@logger)
|
36
|
-
end
|
37
|
-
describe ' an error message' do
|
38
|
-
it 'should send the error message to the console' do
|
39
|
-
@logger.stub!(:last_message).and_return({ :text => 'error message', :level => Dokkit::Logging::ERROR })
|
40
|
-
lambda { @consolelog.update }.should raise_error(RuntimeError, /\[ERROR\] error message/)
|
41
|
-
end
|
42
|
-
end
|
43
|
-
describe ' a warning message' do
|
44
|
-
it 'should send the warning message to the console' do
|
45
|
-
@logger.stub!(:last_message).and_return({ :text => 'warning message', :level => Dokkit::Logging::WARNING })
|
46
|
-
capture_stderr do
|
47
|
-
@consolelog.update
|
48
|
-
end.should match(/\[WARNING\] warning message/)
|
49
|
-
end
|
50
|
-
end
|
51
|
-
describe ' an info message' do
|
52
|
-
it 'should send the info message to the console' do
|
53
|
-
@logger.stub!(:last_message).and_return({ :text => 'info message', :level => Dokkit::Logging::INFO })
|
54
|
-
capture_stdout do
|
55
|
-
@consolelog.update
|
56
|
-
end.should match(/\[INFO\] info message/)
|
57
|
-
end
|
58
|
-
end
|
59
|
-
describe ' a debug message' do
|
60
|
-
it 'should send the debug message the console' do
|
61
|
-
@logger.stub!(:last_message).and_return({ :text => 'debug message', :level => Dokkit::Logging::DEBUG })
|
62
|
-
capture_stdout do
|
63
|
-
@consolelog.update
|
64
|
-
end.should match(/\[DEBUG\] debug message/)
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
@@ -1,32 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# File 'data_spec.rb' created on 16 apr 2008 at 20:03:08.
|
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/data_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/resource/data'
|
17
|
-
require 'spec/spec_helper.rb'
|
18
|
-
|
19
|
-
describe Dokkit::Resource::Data do
|
20
|
-
before do
|
21
|
-
@data = Dokkit::Resource::Data.new('doc/data/data_1')
|
22
|
-
end
|
23
|
-
it 'should respond to :source_fn' do
|
24
|
-
@data.should respond_to(:source_fn)
|
25
|
-
end
|
26
|
-
it 'should respond to :configuration' do
|
27
|
-
@data.should respond_to(:configuration)
|
28
|
-
end
|
29
|
-
it 'should return the target filename' do
|
30
|
-
@data.target_fn.should == 'output/data_1'
|
31
|
-
end
|
32
|
-
end
|
@@ -1,523 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# File 'document_spec.rb' created on 17 apr 2008 at 18:01:58.
|
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/document_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/resource/document'
|
17
|
-
require 'spec/spec_helper.rb'
|
18
|
-
|
19
|
-
describe Dokkit::Resource::Document, '#include' do
|
20
|
-
include SpecHelper::Logger, SpecHelper::Cache, SpecHelper::Configuration, SpecHelper::Resource
|
21
|
-
before(:all) do
|
22
|
-
@initial_dir = Dir.pwd
|
23
|
-
Dir.chdir(File.join(File.dirname(__FILE__), SpecHelper::Path::TEST_DATA))
|
24
|
-
end
|
25
|
-
before do
|
26
|
-
@logger = logger
|
27
|
-
@filter_factory = filter_factory
|
28
|
-
@cache = cache
|
29
|
-
@document = Dokkit::Resource::Document.new('doc/pages/subdir/document.ext',
|
30
|
-
configuration,
|
31
|
-
@logger,
|
32
|
-
@cache,
|
33
|
-
@resource_factory,
|
34
|
-
@filter_factory)
|
35
|
-
File.stub!(:read).and_return('<%= "erb" %>')
|
36
|
-
end
|
37
|
-
after(:all) do
|
38
|
-
Dir.chdir(@initial_dir)
|
39
|
-
end
|
40
|
-
it 'should read the given file processing it with erb' do
|
41
|
-
File.should_receive(:read).with('included.html').and_return('<%= "erb" %>')
|
42
|
-
@document.include('included.html')
|
43
|
-
end
|
44
|
-
it 'should process the given file with erb' do
|
45
|
-
@erb = ERB.new('<%= "erb" %>')
|
46
|
-
ERB.should_receive(:new).with('<%= "erb" %>').and_return(@erb)
|
47
|
-
@document.include('included.html').should == "erb"
|
48
|
-
end
|
49
|
-
it 'should add the given file as dependency' do
|
50
|
-
@cache.should_receive(:add_dependency).with('doc/pages/subdir/document.ext', 'html', 'included.html')
|
51
|
-
@document.include('included.html')
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
describe Dokkit::Resource::Document, ' when inizialized with a code block' do
|
56
|
-
include SpecHelper::Logger, SpecHelper::Cache, SpecHelper::Configuration, SpecHelper::Resource
|
57
|
-
before(:all) do
|
58
|
-
@initial_dir = Dir.pwd
|
59
|
-
Dir.chdir(File.join(File.dirname(__FILE__), SpecHelper::Path::TEST_DATA))
|
60
|
-
end
|
61
|
-
before do
|
62
|
-
module Extension; def foo; end; end
|
63
|
-
end
|
64
|
-
before do
|
65
|
-
@document = Dokkit::Resource::Document.new('doc/pages/subdir/document.ext',
|
66
|
-
configuration,
|
67
|
-
logger,
|
68
|
-
cache,
|
69
|
-
resource_factory,
|
70
|
-
filter_factory) { |document| document.extend Extension }
|
71
|
-
end
|
72
|
-
after(:all) do
|
73
|
-
Dir.chdir(@initial_dir)
|
74
|
-
end
|
75
|
-
it 'should be extended with Extension module' do
|
76
|
-
@document.respond_to?(:foo).should be_true
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
describe Dokkit::Resource::Document, ' when inizialized with document.ext' do
|
81
|
-
include SpecHelper::Logger, SpecHelper::Cache, SpecHelper::Configuration, SpecHelper::Resource
|
82
|
-
before(:all) do
|
83
|
-
@initial_dir = Dir.pwd
|
84
|
-
Dir.chdir(File.join(File.dirname(__FILE__), SpecHelper::Path::TEST_DATA))
|
85
|
-
end
|
86
|
-
before do
|
87
|
-
@logger = logger
|
88
|
-
@filter_factory = filter_factory
|
89
|
-
@document = Dokkit::Resource::Document.new('doc/pages/subdir/document.ext',
|
90
|
-
configuration,
|
91
|
-
@logger,
|
92
|
-
cache,
|
93
|
-
@resource_factory,
|
94
|
-
@filter_factory)
|
95
|
-
end
|
96
|
-
after(:all) do
|
97
|
-
Dir.chdir(@initial_dir)
|
98
|
-
end
|
99
|
-
it 'should set a default output' do
|
100
|
-
@document.default_format.should == 'html'
|
101
|
-
end
|
102
|
-
it 'should have targets hash' do
|
103
|
-
@document.targets.should
|
104
|
-
end
|
105
|
-
it 'should set a default target filename for a given output format' do
|
106
|
-
@document.target_for(@document.default_format).should == 'output/subdir/document.html'
|
107
|
-
end
|
108
|
-
it 'should have a default filter chain for the default output format' do
|
109
|
-
@document.filters_for(@document.default_format).should == ['erb', 'deplate-html']
|
110
|
-
end
|
111
|
-
it 'should have a default filter chain for latex output' do
|
112
|
-
@document.filters_for('latex').should == ['erb', 'deplate-latex']
|
113
|
-
end
|
114
|
-
it 'should have a default filter chain for text output' do
|
115
|
-
@document.filters_for('text').should == ['erb', 'deplate-text']
|
116
|
-
end
|
117
|
-
it 'should fail if a filter chain for a given output format was not found' do
|
118
|
-
@logger.should_receive(:error).with(/defined filter/)
|
119
|
-
@document.filters_for('notexists')
|
120
|
-
end
|
121
|
-
it 'should return the target filename for the given format' do
|
122
|
-
@document.target_for('html').should == 'output/subdir/document.html'
|
123
|
-
end
|
124
|
-
it 'should set the source file basename' do
|
125
|
-
@document.basename.should == 'document'
|
126
|
-
end
|
127
|
-
it 'should set the dirname' do
|
128
|
-
@document.dirname.should == 'doc/pages/subdir'
|
129
|
-
end
|
130
|
-
it 'should set the filename with path but without extension' do
|
131
|
-
@document.name_noext == 'doc/pages/subdir/document'
|
132
|
-
end
|
133
|
-
it 'should set name relative to document directory' do
|
134
|
-
@document.relativename == 'subdir/document'
|
135
|
-
end
|
136
|
-
it 'should read the content of the source file' do
|
137
|
-
@document.source.should match(/\* Title for document/)
|
138
|
-
end
|
139
|
-
it 'should not store header information in the source text' do
|
140
|
-
@document.source.should_not match(/^-{3}$(.*?)-{3}$/m)
|
141
|
-
end
|
142
|
-
it 'should configure itself through configuration files' do
|
143
|
-
@document.configuration.should == merge_hashes(configuration,
|
144
|
-
'doc/configs/required.yaml',
|
145
|
-
'doc/pages/subdir/document.yaml',
|
146
|
-
'doc/pages/subdir/COMMON.yaml',
|
147
|
-
'doc/pages/COMMON.yaml',
|
148
|
-
'doc/configs/subdir/document.yaml',
|
149
|
-
{ 'key_in_header' => 'value in header'}
|
150
|
-
)
|
151
|
-
end
|
152
|
-
it 'should collect config filenames' do
|
153
|
-
@document.config_fns.should == ['doc/configs/subdir/document.yaml',
|
154
|
-
File.expand_path('doc/pages/COMMON.yaml'),
|
155
|
-
File.expand_path('doc/pages/subdir/COMMON.yaml'),
|
156
|
-
'doc/pages/subdir/document.yaml',
|
157
|
-
'doc/configs/required.yaml',
|
158
|
-
'doc/pages/subdir/document.ext']
|
159
|
-
end
|
160
|
-
it 'should collect layout filenames grouped by format' do
|
161
|
-
@document.layouts['html'].should == ['doc/layouts/subdir/document.html']
|
162
|
-
end
|
163
|
-
it 'should collect target filename' do
|
164
|
-
@document.target_for('html').should == 'output/subdir/document.html'
|
165
|
-
end
|
166
|
-
it 'should store the names of its dependencies grouped by format' do
|
167
|
-
@document.deps_for('html').should == ['doc/pages/subdir/document.ext',
|
168
|
-
'doc/configs/subdir/document.yaml',
|
169
|
-
File.expand_path('doc/pages/COMMON.yaml'),
|
170
|
-
File.expand_path('doc/pages/subdir/COMMON.yaml'),
|
171
|
-
'doc/pages/subdir/document.yaml',
|
172
|
-
'doc/configs/required.yaml',
|
173
|
-
'doc/layouts/subdir/document.html']
|
174
|
-
end
|
175
|
-
it 'should fail if config file doesn''t exist' do
|
176
|
-
@logger.should_receive(:error).with("Configuration file 'notexists' not found for '#{@document.source_fn}'!")
|
177
|
-
@document.add_config('notexists')
|
178
|
-
end
|
179
|
-
it 'should warn if a configuration key doesn''t exist' do
|
180
|
-
@logger.should_receive(:warn)
|
181
|
-
@document.configuration['notexists']
|
182
|
-
end
|
183
|
-
it 'should associate a default value for a not defined configuration key' do
|
184
|
-
@logger.should_receive(:warn)
|
185
|
-
@document.configuration['notexists'].should == @document.default_configuration_value
|
186
|
-
end
|
187
|
-
describe ' and rendered in html' do
|
188
|
-
before do
|
189
|
-
@filter = mock('filter')
|
190
|
-
@filter.stub!(:filter)
|
191
|
-
end
|
192
|
-
it 'should use erb and deplate-html filters' do
|
193
|
-
@filter_factory.should_receive(:get).twice.with('erb', :anything).and_return(@filter)
|
194
|
-
@filter_factory.should_receive(:get).with('deplate-html', :anything).and_return(@filter)
|
195
|
-
@document.render
|
196
|
-
end
|
197
|
-
end
|
198
|
-
|
199
|
-
describe ' and rendered in a unknown format' do
|
200
|
-
it 'should fail if output format doesn''t exist' do
|
201
|
-
@logger.should_receive(:error).with(/format.*is unknown/)
|
202
|
-
@document.render(:format => 'notexists')
|
203
|
-
end
|
204
|
-
end
|
205
|
-
end
|
206
|
-
|
207
|
-
describe Dokkit::Resource::Document, ' when inizialized with document_with_many_targets.ext' do
|
208
|
-
include SpecHelper::Logger, SpecHelper::Cache, SpecHelper::Configuration, SpecHelper::Resource
|
209
|
-
before(:all) do
|
210
|
-
@initial_dir = Dir.pwd
|
211
|
-
Dir.chdir(File.join(File.dirname(__FILE__), SpecHelper::Path::TEST_DATA))
|
212
|
-
end
|
213
|
-
before do
|
214
|
-
@logger = logger
|
215
|
-
@logger.stub!(:warn)
|
216
|
-
@filter_factory = filter_factory
|
217
|
-
@document = Dokkit::Resource::Document.new('doc/pages/document_with_many_targets.ext',
|
218
|
-
configuration,
|
219
|
-
@logger,
|
220
|
-
cache,
|
221
|
-
@resource_factory,
|
222
|
-
@filter_factory
|
223
|
-
)
|
224
|
-
end
|
225
|
-
after(:all) do
|
226
|
-
Dir.chdir(@initial_dir)
|
227
|
-
end
|
228
|
-
it 'should collect all the targets grouped by format' do
|
229
|
-
@document.targets.should == {
|
230
|
-
# 'html' => { :target_fn => 'output/document_with_many_targets.html' },
|
231
|
-
'latex' => { :target_fn => 'output/document_with_many_targets.latex' },
|
232
|
-
'text' => { :target_fn => 'output/document_with_many_targets.text' },
|
233
|
-
'custom' => {
|
234
|
-
:target_fn => 'output/document_with_many_targets.html',
|
235
|
-
'postfilter' => ['erb'],
|
236
|
-
'filter' => ['maruku-html']
|
237
|
-
}
|
238
|
-
}
|
239
|
-
end
|
240
|
-
it 'should return filter_chain for custom format' do
|
241
|
-
@document.filters_for('custom').should == ['maruku-html']
|
242
|
-
end
|
243
|
-
# describe ' and rendered in html format' do
|
244
|
-
# it 'should produce html output' do
|
245
|
-
# result = "<h1>Title</h1>"
|
246
|
-
# filter = mock('filter', :filter => result)
|
247
|
-
# @filter_factory.should_receive(:get).with('deplate-html').and_return(filter)
|
248
|
-
# @document.render(:format => 'html').should match(/#{result}/)
|
249
|
-
# end
|
250
|
-
# end
|
251
|
-
describe ' and rendered in latex format' do
|
252
|
-
before do
|
253
|
-
@filter = mock('filter')
|
254
|
-
@filter.stub!(:filter)
|
255
|
-
end
|
256
|
-
it 'should use erb and deplate-latex filters' do
|
257
|
-
@filter_factory.should_receive(:get).twice.with('erb', :anything).and_return(@filter)
|
258
|
-
@filter_factory.should_receive(:get).with('deplate-latex', :anything).and_return(@filter)
|
259
|
-
@document.render(:format => 'latex')
|
260
|
-
end
|
261
|
-
end
|
262
|
-
describe ' and rendered in text format' do
|
263
|
-
before do
|
264
|
-
@filter = mock('filter')
|
265
|
-
@filter.stub!(:filter)
|
266
|
-
end
|
267
|
-
it 'should use erb and deplate-text filters' do
|
268
|
-
@filter_factory.should_receive(:get).with('erb', :anything).and_return(@filter)
|
269
|
-
@filter_factory.should_receive(:get).with('deplate-text', :anything).and_return(@filter)
|
270
|
-
@document.render(:format => 'text')
|
271
|
-
end
|
272
|
-
end
|
273
|
-
describe ' and rendered in custom format' do
|
274
|
-
it 'should produce html output using maruku' do
|
275
|
-
result = "<h1>Title</h1>"
|
276
|
-
filter = mock('filter', :filter => result)
|
277
|
-
@filter_factory.should_receive(:get).with('maruku-html', :anything).and_return(filter)
|
278
|
-
@document.render(:format => 'custom').should match(/#{result}/)
|
279
|
-
end
|
280
|
-
end
|
281
|
-
end
|
282
|
-
|
283
|
-
describe Dokkit::Resource::Document, ' when inizialized with document_with_nested_layout.ext' do
|
284
|
-
include SpecHelper::Logger, SpecHelper::Cache, SpecHelper::Configuration, SpecHelper::Resource, SpecHelper::Filter
|
285
|
-
before(:all) do
|
286
|
-
@initial_dir = Dir.pwd
|
287
|
-
Dir.chdir(File.join(File.dirname(__FILE__), SpecHelper::Path::TEST_DATA))
|
288
|
-
end
|
289
|
-
before do
|
290
|
-
@logger = logger
|
291
|
-
@filter_factory = filter_factory
|
292
|
-
@document = Dokkit::Resource::Document.new('doc/pages/document_with_nested_layout.ext',
|
293
|
-
configuration,
|
294
|
-
@logger,
|
295
|
-
cache,
|
296
|
-
@resource_factory,
|
297
|
-
@filter_factory
|
298
|
-
)
|
299
|
-
end
|
300
|
-
after(:all) do
|
301
|
-
Dir.chdir(@initial_dir)
|
302
|
-
end
|
303
|
-
it 'should collect layouts' do
|
304
|
-
@document.layouts['html'].should == ['doc/layouts/nested/nested.html', 'doc/layouts/container.html']
|
305
|
-
end
|
306
|
-
describe ' and rendered in html format' do
|
307
|
-
it 'should produce html output using layout chain' do
|
308
|
-
@filter_factory.should_receive(:get).with('erb', :anything).and_return(filter('<p>some content</p>'),
|
309
|
-
filter('<div id="nested"><p>some content</p></div>'),
|
310
|
-
filter('<html><div id="nested"><p>some content</p></div></html>'))
|
311
|
-
@filter_factory.should_receive(:get).with('deplate-html', :anything).and_return(filter('<p>some content</p>'))
|
312
|
-
render_result = @document.render
|
313
|
-
render_result.should match(/\A\<html\>/)
|
314
|
-
render_result.should match(/<div id=\"nested\"\>/)
|
315
|
-
render_result.should match(/some content/)
|
316
|
-
end
|
317
|
-
end
|
318
|
-
end
|
319
|
-
|
320
|
-
describe Dokkit::Resource::Document, ' when inizialized with document_with_many_config.ext' do
|
321
|
-
include SpecHelper::Logger, SpecHelper::Cache, SpecHelper::Configuration, SpecHelper::Resource
|
322
|
-
before(:all) do
|
323
|
-
@initial_dir = Dir.pwd
|
324
|
-
Dir.chdir(File.join(File.dirname(__FILE__), SpecHelper::Path::TEST_DATA))
|
325
|
-
end
|
326
|
-
before do
|
327
|
-
@logger = logger
|
328
|
-
@filter_factory = filter_factory
|
329
|
-
@document = Dokkit::Resource::Document.new('doc/pages/document_with_many_config.ext',
|
330
|
-
configuration,
|
331
|
-
@logger,
|
332
|
-
cache,
|
333
|
-
@resource_factory,
|
334
|
-
@filter_factory
|
335
|
-
)
|
336
|
-
end
|
337
|
-
after(:all) do
|
338
|
-
Dir.chdir(@initial_dir)
|
339
|
-
end
|
340
|
-
it 'should collect config files' do
|
341
|
-
@document.config_fns.should include(config_path('config_1.yaml'), config_path('config_2.yaml'))
|
342
|
-
end
|
343
|
-
end
|
344
|
-
|
345
|
-
describe Dokkit::Resource::Document, ' when inizialized with document_with_many_errors.ext' do
|
346
|
-
include SpecHelper::Logger, SpecHelper::Cache, SpecHelper::Configuration, SpecHelper::Resource
|
347
|
-
before(:all) do
|
348
|
-
@initial_dir = Dir.pwd
|
349
|
-
Dir.chdir(File.join(File.dirname(__FILE__), SpecHelper::Path::TEST_DATA))
|
350
|
-
end
|
351
|
-
before do
|
352
|
-
@logger = logger
|
353
|
-
@filter_factory = filter_factory
|
354
|
-
end
|
355
|
-
after(:all) do
|
356
|
-
Dir.chdir(@initial_dir)
|
357
|
-
end
|
358
|
-
it 'should warn that layouts not exist for html and custom output format' do
|
359
|
-
@logger.should_receive(:warn).with(/Layout.* not exists/)
|
360
|
-
@document = Dokkit::Resource::Document.new('doc/pages/document_with_many_errors.ext',
|
361
|
-
configuration,
|
362
|
-
@logger,
|
363
|
-
cache,
|
364
|
-
@resource_factory,
|
365
|
-
@filter_factory)
|
366
|
-
end
|
367
|
-
it 'should not add not existent layout to deps array' do
|
368
|
-
@logger.stub!(:warn)
|
369
|
-
@document = Dokkit::Resource::Document.new('doc/pages/document_with_many_errors.ext',
|
370
|
-
configuration,
|
371
|
-
@logger,
|
372
|
-
cache,
|
373
|
-
resource_factory,
|
374
|
-
@filter_factory)
|
375
|
-
@document.deps['html'].should_not include(nil)
|
376
|
-
end
|
377
|
-
describe ' and rendered' do
|
378
|
-
before do
|
379
|
-
@logger.stub!(:warn)
|
380
|
-
@document = Dokkit::Resource::Document.new('doc/pages/document_with_many_errors.ext',
|
381
|
-
configuration,
|
382
|
-
@logger,
|
383
|
-
cache,
|
384
|
-
@resource_factory,
|
385
|
-
@filter_factory)
|
386
|
-
end
|
387
|
-
it 'should fail if rendered in :notexists format' do
|
388
|
-
@logger.should_receive(:error)
|
389
|
-
@document.render(:format => 'notexists')
|
390
|
-
end
|
391
|
-
end
|
392
|
-
end
|
393
|
-
|
394
|
-
describe Dokkit::Resource::Document, ' when inizialized with document_with_one_target' do
|
395
|
-
include SpecHelper::Logger, SpecHelper::Cache, SpecHelper::Configuration, SpecHelper::Resource
|
396
|
-
before(:all) do
|
397
|
-
@initial_dir = Dir.pwd
|
398
|
-
Dir.chdir(File.join(File.dirname(__FILE__), SpecHelper::Path::TEST_DATA))
|
399
|
-
end
|
400
|
-
before do
|
401
|
-
@logger = logger
|
402
|
-
@logger.stub!(:warn)
|
403
|
-
@filter_factory = filter_factory
|
404
|
-
end
|
405
|
-
before do
|
406
|
-
@document = Dokkit::Resource::Document.new('doc/pages/document_with_one_target.ext',
|
407
|
-
configuration,
|
408
|
-
@logger,
|
409
|
-
cache,
|
410
|
-
@resource_factory,
|
411
|
-
@filter_factory)
|
412
|
-
end
|
413
|
-
after(:all) do
|
414
|
-
Dir.chdir(@initial_dir)
|
415
|
-
end
|
416
|
-
it 'should correctly setup targets' do
|
417
|
-
@document.targets['text'].should == { :target_fn => output_path('document_with_one_target.text') }
|
418
|
-
end
|
419
|
-
end
|
420
|
-
|
421
|
-
# describe Dokkit::Resource::Document, ' when inizialized with document_with_nil_target' do
|
422
|
-
# include SpecHelper::Logger, SpecHelper::Cache, SpecHelper::Configuration, SpecHelper::Resource
|
423
|
-
# before(:all) do
|
424
|
-
# @initial_dir = Dir.pwd
|
425
|
-
# Dir.chdir(File.join(File.dirname(__FILE__), SpecHelper::Path::TEST_DATA))
|
426
|
-
# end
|
427
|
-
# before do
|
428
|
-
# @logger = logger
|
429
|
-
# @logger.stub!(:warn)
|
430
|
-
# @filter_factory = filter_factory
|
431
|
-
# end
|
432
|
-
# after(:all) do
|
433
|
-
# Dir.chdir(@initial_dir)
|
434
|
-
# end
|
435
|
-
# it 'should fail because target format doesn''t exist' do
|
436
|
-
# @logger.should_receive(:error).with(/invalid target/i)
|
437
|
-
# @document = Dokkit::Resource::Document.new('doc/pages/document_with_nil_target.ext',
|
438
|
-
# configuration,
|
439
|
-
# @logger,
|
440
|
-
# cache,
|
441
|
-
# @resource_factory,
|
442
|
-
# @filter_factory)
|
443
|
-
# end
|
444
|
-
# end
|
445
|
-
|
446
|
-
describe Dokkit::Resource::Document, ' when inizialized with document_with_not_defined_target' do
|
447
|
-
include SpecHelper::Logger, SpecHelper::Cache, SpecHelper::Configuration, SpecHelper::Resource
|
448
|
-
before(:all) do
|
449
|
-
@initial_dir = Dir.pwd
|
450
|
-
Dir.chdir(File.join(File.dirname(__FILE__), SpecHelper::Path::TEST_DATA))
|
451
|
-
end
|
452
|
-
before do
|
453
|
-
@logger = logger
|
454
|
-
@logger.stub!(:warn)
|
455
|
-
@filter_factory = filter_factory
|
456
|
-
end
|
457
|
-
after(:all) do
|
458
|
-
Dir.chdir(@initial_dir)
|
459
|
-
end
|
460
|
-
it 'should fail because target format was not defined' do
|
461
|
-
@logger.should_receive(:error).with(/must define format/i)
|
462
|
-
@document = Dokkit::Resource::Document.new('doc/pages/document_with_not_defined_target.ext',
|
463
|
-
configuration,
|
464
|
-
@logger,
|
465
|
-
cache,
|
466
|
-
@resource_factory,
|
467
|
-
@filter_factory)
|
468
|
-
end
|
469
|
-
end
|
470
|
-
|
471
|
-
describe Dokkit::Resource::Document, ' when render partial' do
|
472
|
-
include SpecHelper::Logger, SpecHelper::Cache, SpecHelper::Configuration, SpecHelper::Resource
|
473
|
-
before(:all) do
|
474
|
-
@initial_dir = Dir.pwd
|
475
|
-
Dir.chdir(File.join(File.dirname(__FILE__), SpecHelper::Path::TEST_DATA))
|
476
|
-
end
|
477
|
-
before do
|
478
|
-
@partial = mock('partial')
|
479
|
-
@partial.stub!(:render)
|
480
|
-
@cache = mock('cache')
|
481
|
-
@cache.stub!(:add_dependency)
|
482
|
-
@resource_factory = resource_factory
|
483
|
-
end
|
484
|
-
before do
|
485
|
-
# @document = Dokkit::Resource::Document.new('doc/pages/document_with_partial.ext',
|
486
|
-
# configuration,
|
487
|
-
# @logger,
|
488
|
-
# cache,
|
489
|
-
# @resource_factory,
|
490
|
-
# @filter_factory)
|
491
|
-
end
|
492
|
-
after(:all) do
|
493
|
-
Dir.chdir(@initial_dir)
|
494
|
-
end
|
495
|
-
it 'should instantiate a document object'
|
496
|
-
it 'should cache document'
|
497
|
-
end
|
498
|
-
|
499
|
-
describe Dokkit::Resource::Document, 'post filtering' do
|
500
|
-
include SpecHelper::Logger, SpecHelper::Cache, SpecHelper::Configuration, SpecHelper::Resource
|
501
|
-
include SpecHelper::Filter
|
502
|
-
|
503
|
-
before(:all) do
|
504
|
-
@initial_dir = Dir.pwd
|
505
|
-
Dir.chdir(File.join(File.dirname(__FILE__), SpecHelper::Path::TEST_DATA))
|
506
|
-
end
|
507
|
-
after(:all) do
|
508
|
-
Dir.chdir(@initial_dir)
|
509
|
-
end
|
510
|
-
before do
|
511
|
-
@filter_factory = filter_factory
|
512
|
-
@document = Dokkit::Resource::Document.new('doc/pages/document_with_postfilter.ext',
|
513
|
-
configuration,
|
514
|
-
logger,
|
515
|
-
cache,
|
516
|
-
resource_factory,
|
517
|
-
@filter_factory)
|
518
|
-
end
|
519
|
-
it 'should postfilter the document' do
|
520
|
-
@filter_factory.should_receive(:get).twice.with('erb', :anything).twice.and_return(filter('filtered output'))
|
521
|
-
@document.render
|
522
|
-
end
|
523
|
-
end
|