spec/nanoc/base/services/outdatedness_checker_spec.rb in nanoc-4.7.12 vs spec/nanoc/base/services/outdatedness_checker_spec.rb in nanoc-4.7.13
- old
+ new
@@ -26,12 +26,12 @@
let(:dependency_store) do
Nanoc::Int::DependencyStore.new(items, layouts, config)
end
- let(:items) { Nanoc::Int::IdentifiableCollection.new(config, [item]) }
- let(:layouts) { Nanoc::Int::IdentifiableCollection.new(config) }
+ let(:items) { Nanoc::Int::ItemCollection.new(config, [item]) }
+ let(:layouts) { Nanoc::Int::LayoutCollection.new(config) }
let(:code_snippets) { [] }
let(:site) do
Nanoc::Int::Site.new(
@@ -120,10 +120,60 @@
end
context 'with layout' do
# …
end
+
+ context 'with item collection' do
+ let(:obj) { items }
+
+ context 'no new items' do
+ it { is_expected.to be_nil }
+ end
+
+ context 'new items' do
+ before do
+ dependency_store.store
+
+ new_item = Nanoc::Int::Item.new('stuff', {}, '/newblahz.md')
+ dependency_store.items = Nanoc::Int::ItemCollection.new(config, [item, new_item])
+
+ dependency_store.load
+ end
+
+ it { is_expected.to be_a(Nanoc::Int::OutdatednessReasons::ItemCollectionExtended) }
+
+ it 'includes proper raw_content props' do
+ expect(subject.objects.map(&:identifier).map(&:to_s)).to eq(['/newblahz.md'])
+ end
+ end
+ end
+
+ context 'with layout collection' do
+ let(:obj) { layouts }
+
+ context 'no new layouts' do
+ it { is_expected.to be_nil }
+ end
+
+ context 'new layouts' do
+ before do
+ dependency_store.store
+
+ new_layout = Nanoc::Int::Layout.new('stuff', {}, '/newblahz.md')
+ dependency_store.layouts = Nanoc::Int::LayoutCollection.new(config, layouts.to_a + [new_layout])
+
+ dependency_store.load
+ end
+
+ it { is_expected.to be_a(Nanoc::Int::OutdatednessReasons::LayoutCollectionExtended) }
+
+ it 'includes proper raw_content props' do
+ expect(subject.objects.map(&:identifier).map(&:to_s)).to eq(['/newblahz.md'])
+ end
+ end
+ end
end
describe '#outdated_due_to_dependencies?' do
subject { outdatedness_checker.send(:outdated_due_to_dependencies?, item) }
@@ -132,11 +182,11 @@
let(:other_item) { Nanoc::Int::Item.new('other stuff', {}, '/other.md') }
let(:other_item_rep) { Nanoc::Int::ItemRep.new(other_item, :default) }
let(:config) { Nanoc::Int::Configuration.new }
- let(:items) { Nanoc::Int::IdentifiableCollection.new(config, [item, other_item]) }
+ let(:items) { Nanoc::Int::ItemCollection.new(config, [item, other_item]) }
let(:old_action_sequence_for_other_item_rep) do
Nanoc::Int::ActionSequence.build(other_item_rep) do |b|
b.add_filter(:erb, {})
end
@@ -165,11 +215,11 @@
context 'transitive dependency' do
let(:distant_item) { Nanoc::Int::Item.new('distant stuff', {}, '/distant.md') }
let(:distant_item_rep) { Nanoc::Int::ItemRep.new(distant_item, :default) }
let(:items) do
- Nanoc::Int::IdentifiableCollection.new(config, [item, other_item, distant_item])
+ Nanoc::Int::ItemCollection.new(config, [item, other_item, distant_item])
end
let(:action_sequences) do
{
item_rep => new_action_sequence_for_item_rep,
@@ -484,9 +534,245 @@
end
context 'raw content changed' do
before { other_item.content = Nanoc::Int::TextualContent.new('omg new content') }
it { is_expected.not_to be }
+ end
+ end
+
+ context 'only item collection dependency' do
+ context 'dependency on any new item' do
+ before do
+ dependency_tracker = Nanoc::Int::DependencyTracker.new(dependency_store)
+ dependency_tracker.enter(item)
+ dependency_tracker.bounce(items, raw_content: true)
+ dependency_store.store
+ end
+
+ context 'nothing changed' do
+ it { is_expected.not_to be }
+ end
+
+ context 'item added' do
+ before do
+ new_item = Nanoc::Int::Item.new('stuff', {}, '/newblahz.md')
+ dependency_store.items = Nanoc::Int::ItemCollection.new(config, items.to_a + [new_item])
+ dependency_store.load
+ end
+
+ it { is_expected.to be }
+ end
+
+ context 'item removed' do
+ before do
+ dependency_store.items = Nanoc::Int::ItemCollection.new(config, [])
+ dependency_store.load
+ end
+
+ it { is_expected.not_to be }
+ end
+ end
+
+ context 'dependency on specific new items (string)' do
+ before do
+ dependency_tracker = Nanoc::Int::DependencyTracker.new(dependency_store)
+ dependency_tracker.enter(item)
+ dependency_tracker.bounce(items, raw_content: ['/new*'])
+ dependency_store.store
+ end
+
+ context 'nothing changed' do
+ it { is_expected.not_to be }
+ end
+
+ context 'matching item added' do
+ before do
+ new_item = Nanoc::Int::Item.new('stuff', {}, '/newblahz.md')
+ dependency_store.items = Nanoc::Int::ItemCollection.new(config, items.to_a + [new_item])
+ dependency_store.load
+ end
+
+ it { is_expected.to be }
+ end
+
+ context 'non-matching item added' do
+ before do
+ new_item = Nanoc::Int::Item.new('stuff', {}, '/nublahz.md')
+ dependency_store.items = Nanoc::Int::ItemCollection.new(config, items.to_a + [new_item])
+ dependency_store.load
+ end
+
+ it { is_expected.not_to be }
+ end
+
+ context 'item removed' do
+ before do
+ dependency_store.items = Nanoc::Int::ItemCollection.new(config, [])
+ dependency_store.load
+ end
+
+ it { is_expected.not_to be }
+ end
+ end
+
+ context 'dependency on specific new items (regex)' do
+ before do
+ dependency_tracker = Nanoc::Int::DependencyTracker.new(dependency_store)
+ dependency_tracker.enter(item)
+ dependency_tracker.bounce(items, raw_content: [%r{^/new.*}])
+ dependency_store.store
+ end
+
+ context 'nothing changed' do
+ it { is_expected.not_to be }
+ end
+
+ context 'matching item added' do
+ before do
+ new_item = Nanoc::Int::Item.new('stuff', {}, '/newblahz.md')
+ dependency_store.items = Nanoc::Int::ItemCollection.new(config, items.to_a + [new_item])
+ dependency_store.load
+ end
+
+ it { is_expected.to be }
+ end
+
+ context 'non-matching item added' do
+ before do
+ new_item = Nanoc::Int::Item.new('stuff', {}, '/nublahz.md')
+ dependency_store.items = Nanoc::Int::ItemCollection.new(config, items.to_a + [new_item])
+ dependency_store.load
+ end
+
+ it { is_expected.not_to be }
+ end
+
+ context 'item removed' do
+ before do
+ dependency_store.items = Nanoc::Int::ItemCollection.new(config, [])
+ dependency_store.load
+ end
+
+ it { is_expected.not_to be }
+ end
+ end
+ end
+
+ context 'only layout collection dependency' do
+ context 'dependency on any new layout' do
+ before do
+ dependency_tracker = Nanoc::Int::DependencyTracker.new(dependency_store)
+ dependency_tracker.enter(item)
+ dependency_tracker.bounce(layouts, raw_content: true)
+ dependency_store.store
+ end
+
+ context 'nothing changed' do
+ it { is_expected.not_to be }
+ end
+
+ context 'layout added' do
+ before do
+ new_layout = Nanoc::Int::Layout.new('stuff', {}, '/newblahz.md')
+ dependency_store.layouts = Nanoc::Int::LayoutCollection.new(config, layouts.to_a + [new_layout])
+ dependency_store.load
+ end
+
+ it { is_expected.to be }
+ end
+
+ context 'layout removed' do
+ before do
+ dependency_store.layouts = Nanoc::Int::LayoutCollection.new(config, [])
+ dependency_store.load
+ end
+
+ it { is_expected.not_to be }
+ end
+ end
+
+ context 'dependency on specific new layouts (string)' do
+ before do
+ dependency_tracker = Nanoc::Int::DependencyTracker.new(dependency_store)
+ dependency_tracker.enter(item)
+ dependency_tracker.bounce(layouts, raw_content: ['/new*'])
+ dependency_store.store
+ end
+
+ context 'nothing changed' do
+ it { is_expected.not_to be }
+ end
+
+ context 'matching layout added' do
+ before do
+ new_layout = Nanoc::Int::Layout.new('stuff', {}, '/newblahz.md')
+ dependency_store.layouts = Nanoc::Int::LayoutCollection.new(config, layouts.to_a + [new_layout])
+ dependency_store.load
+ end
+
+ it { is_expected.to be }
+ end
+
+ context 'non-matching layout added' do
+ before do
+ new_layout = Nanoc::Int::Layout.new('stuff', {}, '/nublahz.md')
+ dependency_store.layouts = Nanoc::Int::LayoutCollection.new(config, layouts.to_a + [new_layout])
+ dependency_store.load
+ end
+
+ it { is_expected.not_to be }
+ end
+
+ context 'layout removed' do
+ before do
+ dependency_store.layouts = Nanoc::Int::LayoutCollection.new(config, [])
+ dependency_store.load
+ end
+
+ it { is_expected.not_to be }
+ end
+ end
+
+ context 'dependency on specific new layouts (regex)' do
+ before do
+ dependency_tracker = Nanoc::Int::DependencyTracker.new(dependency_store)
+ dependency_tracker.enter(item)
+ dependency_tracker.bounce(layouts, raw_content: [%r{^/new.*}])
+ dependency_store.store
+ end
+
+ context 'nothing changed' do
+ it { is_expected.not_to be }
+ end
+
+ context 'matching layout added' do
+ before do
+ new_layout = Nanoc::Int::Layout.new('stuff', {}, '/newblahz.md')
+ dependency_store.layouts = Nanoc::Int::LayoutCollection.new(config, layouts.to_a + [new_layout])
+ dependency_store.load
+ end
+
+ it { is_expected.to be }
+ end
+
+ context 'non-matching layout added' do
+ before do
+ new_layout = Nanoc::Int::Layout.new('stuff', {}, '/nublahz.md')
+ dependency_store.layouts = Nanoc::Int::LayoutCollection.new(config, layouts.to_a + [new_layout])
+ dependency_store.load
+ end
+
+ it { is_expected.not_to be }
+ end
+
+ context 'layout removed' do
+ before do
+ dependency_store.layouts = Nanoc::Int::LayoutCollection.new(config, [])
+ dependency_store.load
+ end
+
+ it { is_expected.not_to be }
+ end
end
end
end
end