@@ -131,6 +131,13 @@ class DocsDocTest < MiniTest::Spec
131131 end
132132 end
133133
134+ describe ".meta_path" do
135+ it "returns .path + ::META_FILENAME" do
136+ stub ( doc ) . path { 'path' }
137+ assert_equal File . join ( 'path' , Docs ::Doc ::META_FILENAME ) , doc . meta_path
138+ end
139+ end
140+
134141 describe ".new" do
135142 it "raises an error when .abstract is true" do
136143 doc . abstract = true
@@ -265,12 +272,14 @@ class DocsDocTest < MiniTest::Spec
265272 mock ( store ) . write ( page [ :store_path ] , page [ :output ] )
266273 mock ( store ) . write ( 'index.json' , anything )
267274 mock ( store ) . write ( 'db.json' , anything )
275+ mock ( store ) . write ( 'meta.json' , anything )
268276 doc . store_pages ( store )
269277 end
270278
271279 it "stores an index that contains all the pages' entries" do
272280 stub ( store ) . write ( page [ :store_path ] , page [ :output ] )
273281 stub ( store ) . write ( 'db.json' , anything )
282+ stub ( store ) . write ( 'meta.json' , anything )
274283 mock ( store ) . write ( 'index.json' , anything ) do |path , json |
275284 json = JSON . parse ( json )
276285 assert_equal pages . length , json [ 'entries' ] . length
@@ -282,13 +291,25 @@ class DocsDocTest < MiniTest::Spec
282291 it "stores a db that contains all the pages, indexed by path" do
283292 stub ( store ) . write ( page [ :store_path ] , page [ :output ] )
284293 stub ( store ) . write ( 'index.json' , anything )
294+ stub ( store ) . write ( 'meta.json' , anything )
285295 mock ( store ) . write ( 'db.json' , anything ) do |path , json |
286296 json = JSON . parse ( json )
287297 assert_equal page [ :output ] , json [ page [ :path ] ]
288298 end
289299 doc . store_pages ( store )
290300 end
291301
302+ it "stores a meta file that contains the doc's metadata" do
303+ stub ( store ) . write ( page [ :store_path ] , page [ :output ] )
304+ stub ( store ) . write ( 'index.json' , anything )
305+ stub ( store ) . write ( 'db.json' , anything )
306+ mock ( store ) . write ( 'meta.json' , anything ) do |path , json |
307+ json = JSON . parse ( json )
308+ assert_equal %w( name slug type mtime db_size ) . sort , json . keys . sort
309+ end
310+ doc . store_pages ( store )
311+ end
312+
292313 it "replaces the .path directory before storing the files" do
293314 stub ( doc ) . path { 'path' }
294315 stub ( store ) . write { assert false }
0 commit comments