spec/nanoc/base/services/outdatedness_checker_spec.rb in nanoc-4.7.3 vs spec/nanoc/base/services/outdatedness_checker_spec.rb in nanoc-4.7.4

- old
+ new

@@ -2,11 +2,11 @@ let(:outdatedness_checker) do described_class.new( site: site, checksum_store: checksum_store, dependency_store: dependency_store, - rule_memory_store: rule_memory_store, + action_sequence_store: action_sequence_store, action_provider: action_provider, reps: reps, ) end @@ -24,21 +24,21 @@ code_snippets: [], data_source: Nanoc::Int::InMemDataSource.new([], []), ) end - let(:rule_memory_store) do - Nanoc::Int::RuleMemoryStore.new + let(:action_sequence_store) do + Nanoc::Int::ActionSequenceStore.new end - let(:old_memory_for_item_rep) do - Nanoc::Int::RuleMemory.new(item_rep).tap do |mem| + let(:old_action_sequence_for_item_rep) do + Nanoc::Int::ActionSequence.new(item_rep).tap do |mem| mem.add_filter(:erb, {}) end end - let(:new_memory_for_item_rep) { old_memory_for_item_rep } + let(:new_action_sequence_for_item_rep) { old_action_sequence_for_item_rep } let(:action_provider) { double(:action_provider) } let(:reps) do Nanoc::Int::ItemRepRepo.new @@ -49,13 +49,13 @@ let(:objects) { [item] } before do reps << item_rep - rule_memory_store[item_rep] = old_memory_for_item_rep.serialize + action_sequence_store[item_rep] = old_action_sequence_for_item_rep.serialize - allow(action_provider).to receive(:memory_for).with(item_rep).and_return(new_memory_for_item_rep) + allow(action_provider).to receive(:action_sequence_for).with(item_rep).and_return(new_action_sequence_for_item_rep) end describe '#basic_outdatedness_reason_for' do subject { outdatedness_checker.send(:basic_outdatedness_reason_for, obj) } @@ -71,13 +71,13 @@ end context 'with item' do let(:obj) { item } - context 'rule memory differs' do - let(:new_memory_for_item_rep) do - Nanoc::Int::RuleMemory.new(item_rep).tap do |mem| + context 'action sequence differs' do + let(:new_action_sequence_for_item_rep) do + Nanoc::Int::ActionSequence.new(item_rep).tap do |mem| mem.add_filter(:super_erb, {}) end end it 'is outdated due to rule differences' do @@ -89,13 +89,13 @@ end context 'with item rep' do let(:obj) { item_rep } - context 'rule memory differs' do - let(:new_memory_for_item_rep) do - Nanoc::Int::RuleMemory.new(item_rep).tap do |mem| + context 'action sequence differs' do + let(:new_action_sequence_for_item_rep) do + Nanoc::Int::ActionSequence.new(item_rep).tap do |mem| mem.add_filter(:super_erb, {}) end end it 'is outdated due to rule differences' do @@ -121,26 +121,26 @@ let(:config) { Nanoc::Int::Configuration.new } let(:objects) { [item, other_item] } - let(:old_memory_for_other_item_rep) do - Nanoc::Int::RuleMemory.new(other_item_rep).tap do |mem| + let(:old_action_sequence_for_other_item_rep) do + Nanoc::Int::ActionSequence.new(other_item_rep).tap do |mem| mem.add_filter(:erb, {}) end end - let(:new_memory_for_other_item_rep) { old_memory_for_other_item_rep } + let(:new_action_sequence_for_other_item_rep) { old_action_sequence_for_other_item_rep } before do reps << other_item_rep - rule_memory_store[other_item_rep] = old_memory_for_other_item_rep.serialize + action_sequence_store[other_item_rep] = old_action_sequence_for_other_item_rep.serialize checksum_store.add(item) checksum_store.add(other_item) checksum_store.add(config) - allow(action_provider).to receive(:memory_for).with(other_item_rep).and_return(new_memory_for_other_item_rep) + allow(action_provider).to receive(:action_sequence_for).with(other_item_rep).and_return(new_action_sequence_for_other_item_rep) allow(site).to receive(:code_snippets).and_return([]) allow(site).to receive(:config).and_return(config) end context 'transitive dependency' do @@ -148,12 +148,12 @@ let(:distant_item_rep) { Nanoc::Int::ItemRep.new(distant_item, :default) } before do reps << distant_item_rep checksum_store.add(distant_item) - rule_memory_store[distant_item_rep] = old_memory_for_other_item_rep.serialize - allow(action_provider).to receive(:memory_for).with(distant_item_rep).and_return(new_memory_for_other_item_rep) + action_sequence_store[distant_item_rep] = old_action_sequence_for_other_item_rep.serialize + allow(action_provider).to receive(:action_sequence_for).with(distant_item_rep).and_return(new_action_sequence_for_other_item_rep) end context 'on attribute + attribute' do before do dependency_store.record_dependency(item, other_item, attributes: true) @@ -215,11 +215,11 @@ end end end end - context 'only attribute dependency' do + context 'only generic attribute dependency' do before do dependency_store.record_dependency(item, other_item, attributes: true) end context 'attribute changed' do @@ -237,21 +237,65 @@ before { other_item.content = Nanoc::Int::TextualContent.new('omg new content') } it { is_expected.to be } end context 'path changed' do - let(:new_memory_for_other_item_rep) do - Nanoc::Int::RuleMemory.new(other_item_rep).tap do |mem| + let(:new_action_sequence_for_other_item_rep) do + Nanoc::Int::ActionSequence.new(other_item_rep).tap do |mem| mem.add_filter(:erb, {}) mem.add_snapshot(:donkey, '/giraffe.txt') end end it { is_expected.not_to be } end end + context 'only specific attribute dependency' do + before do + dependency_store.record_dependency(item, other_item, attributes: [:title]) + end + + context 'attribute changed' do + before { other_item.attributes[:title] = 'omg new title' } + it { is_expected.to be } + end + + context 'other attribute changed' do + before { other_item.attributes[:subtitle] = 'tagline here' } + it { is_expected.not_to be } + end + + context 'raw content changed' do + before { other_item.content = Nanoc::Int::TextualContent.new('omg new content') } + it { is_expected.not_to be } + end + + context 'attribute + raw content changed' do + before { other_item.attributes[:title] = 'omg new title' } + before { other_item.content = Nanoc::Int::TextualContent.new('omg new content') } + it { is_expected.to be } + end + + context 'other attribute + raw content changed' do + before { other_item.attributes[:subtitle] = 'tagline here' } + before { other_item.content = Nanoc::Int::TextualContent.new('omg new content') } + it { is_expected.not_to be } + end + + context 'path changed' do + let(:new_action_sequence_for_other_item_rep) do + Nanoc::Int::ActionSequence.new(other_item_rep).tap do |mem| + mem.add_filter(:erb, {}) + mem.add_snapshot(:donkey, '/giraffe.txt') + end + end + + it { is_expected.not_to be } + end + end + context 'only raw content dependency' do before do dependency_store.record_dependency(item, other_item, raw_content: true) end @@ -270,12 +314,12 @@ before { other_item.content = Nanoc::Int::TextualContent.new('omg new content') } it { is_expected.to be } end context 'path changed' do - let(:new_memory_for_other_item_rep) do - Nanoc::Int::RuleMemory.new(other_item_rep).tap do |mem| + let(:new_action_sequence_for_other_item_rep) do + Nanoc::Int::ActionSequence.new(other_item_rep).tap do |mem| mem.add_filter(:erb, {}) mem.add_snapshot(:donkey, '/giraffe.txt') end end @@ -297,12 +341,12 @@ before { other_item.content = Nanoc::Int::TextualContent.new('omg new content') } it { is_expected.to be } end context 'path changed' do - let(:new_memory_for_other_item_rep) do - Nanoc::Int::RuleMemory.new(other_item_rep).tap do |mem| + let(:new_action_sequence_for_other_item_rep) do + Nanoc::Int::ActionSequence.new(other_item_rep).tap do |mem| mem.add_filter(:erb, {}) mem.add_snapshot(:donkey, '/giraffe.txt') end end @@ -330,11 +374,11 @@ before { other_item.content = Nanoc::Int::TextualContent.new('omg new content') } it { is_expected.to be } end context 'rules changed' do - let(:new_memory_for_other_item_rep) do - Nanoc::Int::RuleMemory.new(other_item_rep).tap do |mem| + let(:new_action_sequence_for_other_item_rep) do + Nanoc::Int::ActionSequence.new(other_item_rep).tap do |mem| mem.add_filter(:erb, {}) mem.add_filter(:donkey, {}) end end