test/base/test_dependency_tracker.rb in nanoc-4.0.2 vs test/base/test_dependency_tracker.rb in nanoc-4.1.0a1

- old
+ new

@@ -2,110 +2,111 @@ def test_initialize # Mock items items = [mock, mock] # Create - tracker = Nanoc::Int::DependencyTracker.new(items) + store = Nanoc::Int::DependencyStore.new(items) # Verify no dependencies yet - assert_empty tracker.objects_causing_outdatedness_of(items[0]) - assert_empty tracker.objects_causing_outdatedness_of(items[1]) + assert_empty store.objects_causing_outdatedness_of(items[0]) + assert_empty store.objects_causing_outdatedness_of(items[1]) end def test_record_dependency # Mock items items = [mock, mock] # Create - tracker = Nanoc::Int::DependencyTracker.new(items) + store = Nanoc::Int::DependencyStore.new(items) # Record some dependencies - tracker.record_dependency(items[0], items[1]) + store.record_dependency(items[0], items[1]) # Verify dependencies - assert_contains_exactly [items[1]], tracker.objects_causing_outdatedness_of(items[0]) + assert_contains_exactly [items[1]], store.objects_causing_outdatedness_of(items[0]) end def test_record_dependency_no_self # Mock items items = [mock, mock] # Create - tracker = Nanoc::Int::DependencyTracker.new(items) + store = Nanoc::Int::DependencyStore.new(items) # Record some dependencies - tracker.record_dependency(items[0], items[0]) - tracker.record_dependency(items[0], items[1]) + store.record_dependency(items[0], items[0]) + store.record_dependency(items[0], items[1]) # Verify dependencies - assert_contains_exactly [items[1]], tracker.objects_causing_outdatedness_of(items[0]) + assert_contains_exactly [items[1]], store.objects_causing_outdatedness_of(items[0]) end def test_record_dependency_no_doubles # Mock items items = [mock, mock] # Create - tracker = Nanoc::Int::DependencyTracker.new(items) + store = Nanoc::Int::DependencyStore.new(items) # Record some dependencies - tracker.record_dependency(items[0], items[1]) - tracker.record_dependency(items[0], items[1]) - tracker.record_dependency(items[0], items[1]) + store.record_dependency(items[0], items[1]) + store.record_dependency(items[0], items[1]) + store.record_dependency(items[0], items[1]) # Verify dependencies - assert_contains_exactly [items[1]], tracker.objects_causing_outdatedness_of(items[0]) + assert_contains_exactly [items[1]], store.objects_causing_outdatedness_of(items[0]) end def test_objects_causing_outdatedness_of # Mock items items = [mock, mock, mock] # Create - tracker = Nanoc::Int::DependencyTracker.new(items) + store = Nanoc::Int::DependencyStore.new(items) # Record some dependencies - tracker.record_dependency(items[0], items[1]) - tracker.record_dependency(items[1], items[2]) + store.record_dependency(items[0], items[1]) + store.record_dependency(items[1], items[2]) # Verify dependencies - assert_contains_exactly [items[1]], tracker.objects_causing_outdatedness_of(items[0]) + assert_contains_exactly [items[1]], store.objects_causing_outdatedness_of(items[0]) end def test_objects_outdated_due_to # Mock items items = [mock, mock, mock] # Create - tracker = Nanoc::Int::DependencyTracker.new(items) + store = Nanoc::Int::DependencyStore.new(items) # Record some dependencies - tracker.record_dependency(items[0], items[1]) - tracker.record_dependency(items[1], items[2]) + store.record_dependency(items[0], items[1]) + store.record_dependency(items[1], items[2]) # Verify dependencies - assert_contains_exactly [items[0]], tracker.objects_outdated_due_to(items[1]) + assert_contains_exactly [items[0]], store.objects_outdated_due_to(items[1]) end def test_start_and_stop # Mock items items = [mock, mock] # Create - tracker = Nanoc::Int::DependencyTracker.new(items) + store = Nanoc::Int::DependencyStore.new(items) + tracker = Nanoc::Int::DependencyTracker.new(store) # Start, do something and stop - tracker.start - Nanoc::Int::NotificationCenter.post(:visit_started, items[0]) - Nanoc::Int::NotificationCenter.post(:visit_started, items[1]) - Nanoc::Int::NotificationCenter.post(:visit_ended, items[1]) - Nanoc::Int::NotificationCenter.post(:visit_ended, items[0]) - tracker.stop + tracker.run do + Nanoc::Int::NotificationCenter.post(:visit_started, items[0]) + Nanoc::Int::NotificationCenter.post(:visit_started, items[1]) + Nanoc::Int::NotificationCenter.post(:visit_ended, items[1]) + Nanoc::Int::NotificationCenter.post(:visit_ended, items[0]) + end # Verify dependencies - assert_contains_exactly [items[1]], tracker.objects_causing_outdatedness_of(items[0]) - assert_empty tracker.objects_causing_outdatedness_of(items[1]) + assert_contains_exactly [items[1]], store.objects_causing_outdatedness_of(items[0]) + assert_empty store.objects_causing_outdatedness_of(items[1]) end def test_store_graph_and_load_graph_simple # Mock items items = [mock('0'), mock('1'), mock('2'), mock('3')] @@ -114,32 +115,32 @@ items[1].stubs(:reference).returns([:item, '/bbb/']) items[2].stubs(:reference).returns([:item, '/ccc/']) items[3].stubs(:reference).returns([:item, '/ddd/']) # Create - tracker = Nanoc::Int::DependencyTracker.new(items) + store = Nanoc::Int::DependencyStore.new(items) # Record some dependencies - tracker.record_dependency(items[0], items[1]) - tracker.record_dependency(items[1], items[2]) - tracker.record_dependency(items[1], items[3]) + store.record_dependency(items[0], items[1]) + store.record_dependency(items[1], items[2]) + store.record_dependency(items[1], items[3]) # Store - tracker.store - assert File.file?(tracker.filename) + store.store + assert File.file?(store.filename) # Re-create - tracker = Nanoc::Int::DependencyTracker.new(items) + store = Nanoc::Int::DependencyStore.new(items) # Load - tracker.load + store.load # Check loaded graph - assert_contains_exactly [items[1]], tracker.objects_causing_outdatedness_of(items[0]) - assert_contains_exactly [items[2], items[3]], tracker.objects_causing_outdatedness_of(items[1]) - assert_empty tracker.objects_causing_outdatedness_of(items[2]) - assert_empty tracker.objects_causing_outdatedness_of(items[3]) + assert_contains_exactly [items[1]], store.objects_causing_outdatedness_of(items[0]) + assert_contains_exactly [items[2], items[3]], store.objects_causing_outdatedness_of(items[1]) + assert_empty store.objects_causing_outdatedness_of(items[2]) + assert_empty store.objects_causing_outdatedness_of(items[3]) end def test_store_graph_and_load_graph_with_removed_items # Mock items items = [mock('0'), mock('1'), mock('2'), mock('3')] @@ -152,31 +153,31 @@ # Create new and old lists old_items = [items[0], items[1], items[2], items[3]] new_items = [items[0], items[1], items[2]] # Create - tracker = Nanoc::Int::DependencyTracker.new(old_items) + store = Nanoc::Int::DependencyStore.new(old_items) # Record some dependencies - tracker.record_dependency(old_items[0], old_items[1]) - tracker.record_dependency(old_items[1], old_items[2]) - tracker.record_dependency(old_items[1], old_items[3]) + store.record_dependency(old_items[0], old_items[1]) + store.record_dependency(old_items[1], old_items[2]) + store.record_dependency(old_items[1], old_items[3]) # Store - tracker.store - assert File.file?(tracker.filename) + store.store + assert File.file?(store.filename) # Re-create - tracker = Nanoc::Int::DependencyTracker.new(new_items) + store = Nanoc::Int::DependencyStore.new(new_items) # Load - tracker.load + store.load # Check loaded graph - assert_contains_exactly [items[1]], tracker.objects_causing_outdatedness_of(items[0]) - assert_contains_exactly [items[2], nil], tracker.objects_causing_outdatedness_of(items[1]) - assert_empty tracker.objects_causing_outdatedness_of(items[2]) + assert_contains_exactly [items[1]], store.objects_causing_outdatedness_of(items[0]) + assert_contains_exactly [items[2], nil], store.objects_causing_outdatedness_of(items[1]) + assert_empty store.objects_causing_outdatedness_of(items[2]) end def test_store_graph_with_nils_in_dst # Mock items items = [mock('0'), mock('1'), mock('2')] @@ -184,29 +185,29 @@ items[0].stubs(:reference).returns([:item, '/aaa/']) items[1].stubs(:reference).returns([:item, '/bbb/']) items[2].stubs(:reference).returns([:item, '/ccc/']) # Create - tracker = Nanoc::Int::DependencyTracker.new(items) + store = Nanoc::Int::DependencyStore.new(items) # Record some dependencies - tracker.record_dependency(items[0], items[1]) - tracker.record_dependency(items[1], nil) + store.record_dependency(items[0], items[1]) + store.record_dependency(items[1], nil) # Store - tracker.store - assert File.file?(tracker.filename) + store.store + assert File.file?(store.filename) # Re-create - tracker = Nanoc::Int::DependencyTracker.new(items) + store = Nanoc::Int::DependencyStore.new(items) # Load - tracker.load + store.load # Check loaded graph - assert_contains_exactly [items[1]], tracker.objects_causing_outdatedness_of(items[0]) - assert_contains_exactly [nil], tracker.objects_causing_outdatedness_of(items[1]) + assert_contains_exactly [items[1]], store.objects_causing_outdatedness_of(items[0]) + assert_contains_exactly [nil], store.objects_causing_outdatedness_of(items[1]) end def test_store_graph_with_nils_in_src # Mock items items = [mock('0'), mock('1'), mock('2')] @@ -214,43 +215,43 @@ items[0].stubs(:reference).returns([:item, '/aaa/']) items[1].stubs(:reference).returns([:item, '/bbb/']) items[2].stubs(:reference).returns([:item, '/ccc/']) # Create - tracker = Nanoc::Int::DependencyTracker.new(items) + store = Nanoc::Int::DependencyStore.new(items) # Record some dependencies - tracker.record_dependency(items[0], items[1]) - tracker.record_dependency(nil, items[2]) + store.record_dependency(items[0], items[1]) + store.record_dependency(nil, items[2]) # Store - tracker.store - assert File.file?(tracker.filename) + store.store + assert File.file?(store.filename) # Re-create - tracker = Nanoc::Int::DependencyTracker.new(items) + store = Nanoc::Int::DependencyStore.new(items) # Load - tracker.load + store.load # Check loaded graph - assert_contains_exactly [items[1]], tracker.objects_causing_outdatedness_of(items[0]) - assert_empty tracker.objects_causing_outdatedness_of(items[1]) + assert_contains_exactly [items[1]], store.objects_causing_outdatedness_of(items[0]) + assert_empty store.objects_causing_outdatedness_of(items[1]) end def test_forget_dependencies_for # Mock items items = [mock, mock, mock] # Create - tracker = Nanoc::Int::DependencyTracker.new(items) + store = Nanoc::Int::DependencyStore.new(items) # Record some dependencies - tracker.record_dependency(items[0], items[1]) - tracker.record_dependency(items[1], items[2]) - assert_contains_exactly [items[1]], tracker.objects_causing_outdatedness_of(items[0]) + store.record_dependency(items[0], items[1]) + store.record_dependency(items[1], items[2]) + assert_contains_exactly [items[1]], store.objects_causing_outdatedness_of(items[0]) # Forget dependencies - tracker.forget_dependencies_for(items[0]) - assert_empty tracker.objects_causing_outdatedness_of(items[0]) + store.forget_dependencies_for(items[0]) + assert_empty store.objects_causing_outdatedness_of(items[0]) end end