|
|
|
@ -131,6 +131,13 @@ class DocsDocTest < MiniTest::Spec
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
describe ".meta_path" do
|
|
|
|
|
it "returns .path + ::META_FILENAME" do
|
|
|
|
|
stub(doc).path { 'path' }
|
|
|
|
|
assert_equal File.join('path', Docs::Doc::META_FILENAME), doc.meta_path
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
describe ".new" do
|
|
|
|
|
it "raises an error when .abstract is true" do
|
|
|
|
|
doc.abstract = true
|
|
|
|
@ -265,12 +272,14 @@ class DocsDocTest < MiniTest::Spec
|
|
|
|
|
mock(store).write(page[:store_path], page[:output])
|
|
|
|
|
mock(store).write('index.json', anything)
|
|
|
|
|
mock(store).write('db.json', anything)
|
|
|
|
|
mock(store).write('meta.json', anything)
|
|
|
|
|
doc.store_pages(store)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it "stores an index that contains all the pages' entries" do
|
|
|
|
|
stub(store).write(page[:store_path], page[:output])
|
|
|
|
|
stub(store).write('db.json', anything)
|
|
|
|
|
stub(store).write('meta.json', anything)
|
|
|
|
|
mock(store).write('index.json', anything) do |path, json|
|
|
|
|
|
json = JSON.parse(json)
|
|
|
|
|
assert_equal pages.length, json['entries'].length
|
|
|
|
@ -282,6 +291,7 @@ class DocsDocTest < MiniTest::Spec
|
|
|
|
|
it "stores a db that contains all the pages, indexed by path" do
|
|
|
|
|
stub(store).write(page[:store_path], page[:output])
|
|
|
|
|
stub(store).write('index.json', anything)
|
|
|
|
|
stub(store).write('meta.json', anything)
|
|
|
|
|
mock(store).write('db.json', anything) do |path, json|
|
|
|
|
|
json = JSON.parse(json)
|
|
|
|
|
assert_equal page[:output], json[page[:path]]
|
|
|
|
@ -289,6 +299,17 @@ class DocsDocTest < MiniTest::Spec
|
|
|
|
|
doc.store_pages(store)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it "stores a meta file that contains the doc's metadata" do
|
|
|
|
|
stub(store).write(page[:store_path], page[:output])
|
|
|
|
|
stub(store).write('index.json', anything)
|
|
|
|
|
stub(store).write('db.json', anything)
|
|
|
|
|
mock(store).write('meta.json', anything) do |path, json|
|
|
|
|
|
json = JSON.parse(json)
|
|
|
|
|
assert_equal %w(name slug type mtime db_size).sort, json.keys.sort
|
|
|
|
|
end
|
|
|
|
|
doc.store_pages(store)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it "replaces the .path directory before storing the files" do
|
|
|
|
|
stub(doc).path { 'path' }
|
|
|
|
|
stub(store).write { assert false }
|
|
|
|
|