test/helpers/test_blogging.rb in nanoc-4.7.10 vs test/helpers/test_blogging.rb in nanoc-4.7.11

- old
+ new

@@ -26,10 +26,28 @@ item = mock item.stubs(:[]).with(:kind).returns('item') item end + def setup + super + + config = Nanoc::Int::Configuration.new.with_defaults + items = Nanoc::Int::IdentifiableCollection.new(config) + layouts = Nanoc::Int::IdentifiableCollection.new(config) + dep_store = Nanoc::Int::DependencyStore.new(items, layouts) + dependency_tracker = Nanoc::Int::DependencyTracker.new(dep_store) + + @view_context = Nanoc::ViewContext.new( + reps: :__irrelevant__, + items: nil, + dependency_tracker: dependency_tracker, + compilation_context: :__irrelevant__, + snapshot_repo: :__irrelevant_snapshot_repo, + ) + end + def test_atom_feed if_have 'builder' do # Create items @items = [mock, mock_article, mock_article] @@ -49,11 +67,12 @@ # Create item 2 @items[2].expects(:compiled_content).with(snapshot: :pre).returns('item 2 content') # Mock site - @config = Nanoc::ConfigView.new({ base_url: 'http://example.com' }, nil) + config = Nanoc::Int::Configuration.new(hash: { base_url: 'http://example.com' }) + @config = Nanoc::ConfigView.new(config, @view_context) # Create feed item @item = mock @item.stubs(:[]).with(:title).returns('My Cool Blog') @item.stubs(:[]).with(:author_name).returns('Denis Defreyne') @@ -80,11 +99,12 @@ @items[2].stubs(:[]).with(:updated_at).returns(Time.now - 250) @items[2].stubs(:[]).with(:created_at).returns(Time.now - 1200) @items[2].expects(:compiled_content).returns('item 2 content') # Mock site - @config = Nanoc::ConfigView.new({ base_url: 'http://example.com' }, nil) + config = Nanoc::Int::Configuration.new(hash: { base_url: 'http://example.com' }) + @config = Nanoc::ConfigView.new(config, @view_context) # Create feed item @item = mock @item.stubs(:[]).with(:title).returns('My Cool Blog') @item.stubs(:[]).with(:author_name).returns('Denis Defreyne') @@ -111,11 +131,12 @@ @items[2].stubs(:[]).with(:updated_at).returns(nil) @items[2].stubs(:[]).with(:created_at).returns(Time.parse('2016-12-01 18:40:00 +00:00')) @items[2].expects(:compiled_content).returns('item 2 content') # Mock site - @config = Nanoc::ConfigView.new({ base_url: 'http://example.com' }, nil) + config = Nanoc::Int::Configuration.new(hash: { base_url: 'http://example.com' }) + @config = Nanoc::ConfigView.new(config, @view_context) # Create feed item @item = mock @item.stubs(:[]).with(:title).returns('My Cool Blog') @item.stubs(:[]).with(:author_name).returns('Denis Defreyne') @@ -142,11 +163,12 @@ @items[2].stubs(:[]).with(:updated_at).returns(Time.parse('2016-12-01 20:40:00 +00:00')) @items[2].stubs(:[]).with(:created_at).returns(Time.parse('2016-12-01 18:40:00 +00:00')) @items[2].expects(:compiled_content).returns('item 2 content') # Mock site - @config = Nanoc::ConfigView.new({ base_url: 'http://example.com' }, nil) + config = Nanoc::Int::Configuration.new(hash: { base_url: 'http://example.com' }) + @config = Nanoc::ConfigView.new(config, @view_context) # Create feed item @item = mock @item.stubs(:[]).with(:title).returns('My Cool Blog') @item.stubs(:[]).with(:author_name).returns('Denis Defreyne') @@ -163,11 +185,12 @@ if_have 'builder' do # Mock items @items = [mock_item, mock_item] # Mock site - @config = Nanoc::ConfigView.new({ base_url: 'http://example.com' }, nil) + config = Nanoc::Int::Configuration.new(hash: { base_url: 'http://example.com' }) + @config = Nanoc::ConfigView.new(config, @view_context) # Create feed item @item = mock @item.stubs(:[]).with(:title).returns('My Blog Or Something') @item.stubs(:[]).with(:author_name).returns('J. Doe') @@ -188,11 +211,12 @@ if_have 'builder' do # Create items @items = [mock_item, mock_article] # Mock site - @config = Nanoc::ConfigView.new({ base_url: nil }, nil) + config = Nanoc::Int::Configuration.new(hash: { base_url: nil }) + @config = Nanoc::ConfigView.new(config, @view_context) # Create feed item @item = mock @item.stubs(:[]).with(:title).returns('My Blog Or Something') @item.stubs(:[]).with(:author_name).returns('J. Doe') @@ -213,11 +237,12 @@ if_have 'builder' do # Create items @items = [mock_item, mock_article] # Mock site - @config = Nanoc::ConfigView.new({ base_url: 'http://example.com' }, nil) + config = Nanoc::Int::Configuration.new(hash: { base_url: 'http://example.com' }) + @config = Nanoc::ConfigView.new(config, @view_context) # Create feed item @item = mock @item.stubs(:[]).with(:title).returns(nil) @item.stubs(:[]).with(:author_name).returns('J. Doe') @@ -238,11 +263,12 @@ if_have 'builder' do # Create items @items = [mock_item, mock_article] # Mock site - @config = Nanoc::ConfigView.new({ base_url: 'http://example.com' }, nil) + config = Nanoc::Int::Configuration.new(hash: { base_url: 'http://example.com' }) + @config = Nanoc::ConfigView.new(config, @view_context) # Create feed item @item = mock @item.stubs(:[]).with(:title).returns('My Blog Or Something') @item.stubs(:[]).with(:author_name).returns(nil) @@ -268,11 +294,12 @@ @items[0].stubs(:[]).with(:author_name).returns('Don Alias') @items[0].stubs(:[]).with(:author_uri).returns('http://don.example.com/') @items[0].expects(:compiled_content).returns('item 1 content') # Mock site - @config = Nanoc::ConfigView.new({ base_url: 'http://example.com/' }, nil) + config = Nanoc::Int::Configuration.new(hash: { base_url: 'http://example.com/' }) + @config = Nanoc::ConfigView.new(config, @view_context) # Create feed item @item = mock @item.stubs(:[]).with(:kind).returns(nil) @item.stubs(:[]).with(:title).returns('My Cool Blog') @@ -310,11 +337,12 @@ if_have 'builder' do # Create items @items = [mock_item, mock_article] # Mock site - @config = Nanoc::ConfigView.new({ base_url: 'http://example.com' }, nil) + config = Nanoc::Int::Configuration.new(hash: { base_url: 'http://example.com' }) + @config = Nanoc::ConfigView.new(config, @view_context) # Create feed item @item = mock @item.stubs(:[]).with(:title).returns('My Blog Or Something') @item.stubs(:[]).with(:author_name).returns('J. Doe') @@ -337,11 +365,12 @@ @items = [mock_item, mock_article, mock_article] @items[1].stubs(:[]).with(:created_at).returns(Time.now.to_s) @items[2].stubs(:[]).with(:created_at).returns(nil) # Mock site - @config = Nanoc::ConfigView.new({ base_url: 'http://example.com' }, nil) + config = Nanoc::Int::Configuration.new(hash: { base_url: 'http://example.com' }) + @config = Nanoc::ConfigView.new(config, @view_context) # Create feed item @item = mock @item.stubs(:[]).with(:title).returns('My Blog Or Something') @item.stubs(:[]).with(:author_name).returns('J. Doe') @@ -363,11 +392,12 @@ # Create items @items = [mock_item, mock_article] @items[1].expects(:compiled_content).with(snapshot: :pre).returns('asdf') # Mock site - @config = Nanoc::ConfigView.new({ base_url: 'http://example.com' }, nil) + config = Nanoc::Int::Configuration.new(hash: { base_url: 'http://example.com' }) + @config = Nanoc::ConfigView.new(config, @view_context) # Create feed item @item = mock @item.stubs(:[]).with(:title).returns(nil) @item.stubs(:[]).with(:author_name).returns(nil) @@ -388,19 +418,19 @@ # Create items @items = [mock_item, mock_article] @items[1].expects(:compiled_content).with(snapshot: :pre).returns('asdf') # Mock site - @config = Nanoc::ConfigView.new( + config_hash = { author_name: 'Bob', author_uri: 'http://example.com/~bob/', title: 'My Blog Or Something', base_url: 'http://example.com', - }, - nil, - ) + } + config = Nanoc::Int::Configuration.new(hash: config_hash) + @config = Nanoc::ConfigView.new(config, @view_context) # Create feed item @item = mock @item.stubs(:[]).with(:title).returns(nil) @item.stubs(:[]).with(:author_name).returns(nil) @@ -420,11 +450,12 @@ @items[0].expects(:compiled_content).never @items[1].stubs(:[]).with(:title).returns('Item One') @items[1].expects(:compiled_content).with(snapshot: :pre).returns('asdf') # Mock site - @config = Nanoc::ConfigView.new({ base_url: 'http://example.com' }, nil) + config = Nanoc::Int::Configuration.new(hash: { base_url: 'http://example.com' }) + @config = Nanoc::ConfigView.new(config, @view_context) # Create feed item @item = mock @item.stubs(:[]).with(:title).returns('My Blog Or Something') @item.stubs(:[]).with(:author_name).returns('J. Doe') @@ -444,11 +475,12 @@ article.stubs(:[]).with(:title).returns("Article #{i}") article.stubs(:[]).with(:created_at).returns(Time.now - i) end # Mock site - @config = Nanoc::ConfigView.new({ base_url: 'http://example.com' }, nil) + config = Nanoc::Int::Configuration.new(hash: { base_url: 'http://example.com' }) + @config = Nanoc::ConfigView.new(config, @view_context) # Create feed item @item = mock @item.stubs(:[]).with(:title).returns('My Blog Or Something') @item.stubs(:[]).with(:author_name).returns('J. Doe') @@ -477,11 +509,12 @@ end @items[0].stubs(:[]).with(:created_at).returns('23-02-2009') @items[1].stubs(:[]).with(:created_at).returns('22-03-2009') # Mock site - @config = Nanoc::ConfigView.new({ base_url: 'http://example.com' }, nil) + config = Nanoc::Int::Configuration.new(hash: { base_url: 'http://example.com' }) + @config = Nanoc::ConfigView.new(config, @view_context) # Create feed item @item = mock @item.stubs(:[]).with(:title).returns('My Blog Or Something') @item.stubs(:[]).with(:author_name).returns('J. Doe') @@ -506,11 +539,12 @@ end @items[0].stubs(:[]).with(:created_at).returns('01-01-2015') @items[1].stubs(:[]).with(:created_at).returns('01-01-2014') # Mock site - @config = Nanoc::ConfigView.new({ base_url: 'http://example.com' }, nil) + config = Nanoc::Int::Configuration.new(hash: { base_url: 'http://example.com' }) + @config = Nanoc::ConfigView.new(config, @view_context) # Create feed item @item = mock @item.stubs(:[]).with(:title).returns('My Blog Or Something') @item.stubs(:[]).with(:author_name).returns('J. Doe') @@ -530,11 +564,12 @@ if_have 'builder' do # Mock article @items = [mock_article] # Mock site - @config = Nanoc::ConfigView.new({ base_url: 'http://example.com' }, nil) + config = Nanoc::Int::Configuration.new(hash: { base_url: 'http://example.com' }) + @config = Nanoc::ConfigView.new(config, @view_context) # Create feed item @item = mock @item.stubs(:[]).with(:title).returns('My Blog Or Something') @item.stubs(:[]).with(:author_name).returns('J. Doe') @@ -551,11 +586,12 @@ if_have 'builder' do # Mock article @items = [mock_article] # Mock site - @config = Nanoc::ConfigView.new({ base_url: 'http://example.com' }, nil) + config = Nanoc::Int::Configuration.new(hash: { base_url: 'http://example.com' }) + @config = Nanoc::ConfigView.new(config, @view_context) # Create feed item @item = mock @item.stubs(:[]).with(:title).returns('My Blog Or Something') @item.stubs(:[]).with(:author_name).returns('J. Doe') @@ -572,11 +608,12 @@ if_have 'builder' do # Mock article @items = [mock_article] # Mock site - @config = Nanoc::ConfigView.new({ base_url: 'http://example.com' }, nil) + config = Nanoc::Int::Configuration.new(hash: { base_url: 'http://example.com' }) + @config = Nanoc::ConfigView.new(config, @view_context) # Create feed item @item = mock @item.stubs(:[]).with(:title).returns('My Blog Or Something') @item.stubs(:[]).with(:author_name).returns('J. Doe') @@ -593,11 +630,12 @@ if_have 'builder' do # Mock article @items = [mock_article] # Mock site - @config = Nanoc::ConfigView.new({ base_url: 'http://example.com' }, nil) + config = Nanoc::Int::Configuration.new(hash: { base_url: 'http://example.com' }) + @config = Nanoc::ConfigView.new(config, @view_context) # Create feed item @item = mock @item.stubs(:[]).with(:title).returns('My Blog Or Something') @item.stubs(:[]).with(:author_name).returns('J. Doe') @@ -614,11 +652,12 @@ if_have 'builder' do # Mock article @items = [mock_article] # Mock site - @config = Nanoc::ConfigView.new({ base_url: 'http://example.com' }, nil) + config = Nanoc::Int::Configuration.new(hash: { base_url: 'http://example.com' }) + @config = Nanoc::ConfigView.new(config, @view_context) # Create feed item @item = mock @item.stubs(:[]).with(:title).returns('My Blog Or Something') @item.stubs(:[]).with(:author_name).returns('J. Doe') @@ -636,10 +675,11 @@ # Create items @items = [mock_article] @items[0].stubs(:path).returns(nil) # Mock site - @config = Nanoc::ConfigView.new({ base_url: 'http://example.com' }, nil) + config = Nanoc::Int::Configuration.new(hash: { base_url: 'http://example.com' }) + @config = Nanoc::ConfigView.new(config, @view_context) # Create feed item @item = mock @item.stubs(:identifier).returns('/feed/') @item.stubs(:[]).with(:title).returns('My Cool Blog')