|
|
@ -113,12 +113,12 @@ class DocsDocTest < MiniTest::Spec
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
describe ".index_page" do
|
|
|
|
describe ".store_page" do
|
|
|
|
it "builds a page" do
|
|
|
|
it "builds a page" do
|
|
|
|
any_instance_of(doc) do |instance|
|
|
|
|
any_instance_of(doc) do |instance|
|
|
|
|
stub(instance).build_page('id') { @called = true; nil }
|
|
|
|
stub(instance).build_page('id') { @called = true; nil }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
doc.index_page('id') {}
|
|
|
|
doc.store_page(store, 'id') {}
|
|
|
|
assert @called
|
|
|
|
assert @called
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
@ -130,20 +130,23 @@ class DocsDocTest < MiniTest::Spec
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
context "and it has :entries" do
|
|
|
|
context "and it has :entries" do
|
|
|
|
it "yields the page's :store_path and :output" do
|
|
|
|
it "returns true" do
|
|
|
|
doc.index_page('') { |*args| @args = args }
|
|
|
|
assert doc.store_page(store, 'id')
|
|
|
|
assert_equal [page[:store_path], page[:output]], @args
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
it "returns an EntryIndex" do
|
|
|
|
it "stores a file" do
|
|
|
|
assert_instance_of Docs::EntryIndex, doc.index_page('') {}
|
|
|
|
mock(store).write(page[:store_path], page[:output])
|
|
|
|
|
|
|
|
doc.store_page(store, 'id')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
describe "the index" do
|
|
|
|
it "opens the .path directory before storing the file" do
|
|
|
|
it "contains the page's entries" do
|
|
|
|
stub(doc).path { 'path' }
|
|
|
|
index = doc.index_page('') {}
|
|
|
|
stub(store).write { assert false }
|
|
|
|
assert_equal page[:entries], index.entries
|
|
|
|
mock(store).open('path') do |_, block|
|
|
|
|
|
|
|
|
stub(store).write
|
|
|
|
|
|
|
|
block.call
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
doc.store_page(store, 'id')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
@ -152,13 +155,13 @@ class DocsDocTest < MiniTest::Spec
|
|
|
|
page[:entries] = []
|
|
|
|
page[:entries] = []
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
it "doesn't yield" do
|
|
|
|
it "returns false" do
|
|
|
|
doc.index_page('') { |*_| @yield = true }
|
|
|
|
refute doc.store_page(store, 'id')
|
|
|
|
refute @yield
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
it "returns nil" do
|
|
|
|
it "doesn't store a file" do
|
|
|
|
assert_nil doc.index_page('') {}
|
|
|
|
dont_allow(store).write
|
|
|
|
|
|
|
|
doc.store_page(store, 'id')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
@ -170,13 +173,13 @@ class DocsDocTest < MiniTest::Spec
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
it "doesn't yield" do
|
|
|
|
it "returns false" do
|
|
|
|
doc.index_page('') { |*_| @yield = true }
|
|
|
|
refute doc.store_page(store, 'id')
|
|
|
|
refute @yield
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
it "returns nil" do
|
|
|
|
it "doesn't store a file" do
|
|
|
|
assert_nil doc.index_page('') {}
|
|
|
|
dont_allow(store).write
|
|
|
|
|
|
|
|
doc.store_page(store, 'id')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
@ -256,48 +259,6 @@ class DocsDocTest < MiniTest::Spec
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
describe ".store_page" do
|
|
|
|
|
|
|
|
context "when the page is indexed successfully" do
|
|
|
|
|
|
|
|
before do
|
|
|
|
|
|
|
|
stub(doc).index_page('id').yields(page[:store_path], page[:output]) { index }
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it "returns true" do
|
|
|
|
|
|
|
|
assert doc.store_page(store, 'id')
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it "stores a file" do
|
|
|
|
|
|
|
|
mock(store).write(page[:store_path], page[:output])
|
|
|
|
|
|
|
|
doc.store_page(store, 'id')
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it "opens the .path directory before storing the file" do
|
|
|
|
|
|
|
|
stub(doc).path { 'path' }
|
|
|
|
|
|
|
|
stub(store).write { assert false }
|
|
|
|
|
|
|
|
mock(store).open('path') do |_, block|
|
|
|
|
|
|
|
|
stub(store).write
|
|
|
|
|
|
|
|
block.call
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
doc.store_page(store, 'id')
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
context "when the page isn't indexed successfully" do
|
|
|
|
|
|
|
|
before do
|
|
|
|
|
|
|
|
stub(doc).index_page('id') { nil }
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it "returns false" do
|
|
|
|
|
|
|
|
refute doc.store_page(store, 'id')
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it "doesn't store a file" do
|
|
|
|
|
|
|
|
dont_allow(store).write
|
|
|
|
|
|
|
|
doc.store_page(store, 'id')
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
describe ".store_pages" do
|
|
|
|
describe ".store_pages" do
|
|
|
|
context "when pages are indexed successfully" do
|
|
|
|
context "when pages are indexed successfully" do
|
|
|
|
before do
|
|
|
|
before do
|
|
|
|