test/helpers/test_blogging.rb in nanoc-4.0.0b1 vs test/helpers/test_blogging.rb in nanoc-4.0.0b2

- old
+ new

@@ -24,68 +24,10 @@ item = mock item.stubs(:[]).with(:kind).returns('item') item end - def test_articles - # Create items - @items = [ - Nanoc::Int::Item.new( - 'blah', - { kind: 'item' }, - '/0/' - ), - Nanoc::Int::Item.new( - 'blah blah', - { kind: 'article' }, - '/1/' - ), - Nanoc::Int::Item.new( - 'blah blah blah', - { kind: 'article' }, - '/2/' - ) - ] - - # Check - assert_equal(2, articles.size) - assert articles.include?(@items[1]) - assert articles.include?(@items[2]) - ensure - # Cleanup - @items = nil - end - - def test_sorted_articles - # Create items - @items = [ - Nanoc::Int::Item.new( - 'blah', - { kind: 'item' }, - '/0/' - ), - Nanoc::Int::Item.new( - 'blah', - { kind: 'article', created_at: (Date.today - 1).to_s }, - '/1/' - ), - Nanoc::Int::Item.new( - 'blah', - { kind: 'article', created_at: (Time.now - 500).to_s }, - '/2/' - ) - ] - - # Check - assert_equal(2, sorted_articles.size) - assert_equal(@items[2], sorted_articles[0]) - assert_equal(@items[1], sorted_articles[1]) - ensure - # Cleanup - @items = nil - end - def test_atom_feed if_have 'builder' do # Create items @items = [mock, mock_article, mock_article] @@ -620,184 +562,7 @@ @item.stubs(:path).returns('/journal/feed/') # Check atom_feed end - end - - def test_url_for_without_custom_path_in_feed - # Create site - @config = Nanoc::ConfigView.new({ base_url: 'http://example.com' }) - - # Create article - item = Nanoc::Int::Item.new('content', {}, '/foo/') - item.reps << Nanoc::Int::ItemRep.new(item, :default) - item.reps[0].paths[:last] = '/foo/bar/' - - # Check - assert_equal('http://example.com/foo/bar/', url_for(item)) - ensure - # Cleanup - @item = nil - end - - def test_url_for_with_custom_path_in_feed - # Create site - @config = Nanoc::ConfigView.new({ base_url: 'http://example.com' }) - - # Create article - item = Nanoc::Int::Item.new( - 'content', { custom_path_in_feed: '/meow/woof/' }, '/foo/') - item.reps << Nanoc::Int::ItemRep.new(item, :default) - - # Check - assert_equal('http://example.com/meow/woof/', url_for(item)) - ensure - # Cleanup - @item = nil - end - - def test_url_for_with_custom_url_in_feed - # Create site - @config = Nanoc::ConfigView.new({ base_url: 'http://example.com' }) - - # Create article - item = Nanoc::Int::Item.new( - 'content', { custom_url_in_feed: 'http://example.org/x' }, '/foo/') - item.reps << Nanoc::Int::ItemRep.new(item, :default) - - # Check - assert_equal('http://example.org/x', url_for(item)) - ensure - # Cleanup - @item = nil - end - - def test_url_for_without_base_url - # Create site - @config = Nanoc::ConfigView.new({}) - - # Check - assert_raises(Nanoc::Int::Errors::GenericTrivial) do - url_for(nil) - end - end - - def test_url_for_without_path - # Create site - @config = Nanoc::ConfigView.new({ base_url: 'http://example.com' }) - - # Create article - item = Nanoc::Int::Item.new('content', {}, '/foo/') - item.reps << Nanoc::Int::ItemRep.new(item, :default) - item.reps[0].paths[:last] = nil - - # Check - assert_equal(nil, url_for(item)) - end - - def test_feed_url_without_custom_feed_url - # Create site - @config = Nanoc::ConfigView.new({ base_url: 'http://example.com' }) - - # Create article - @item = Nanoc::Int::Item.new('content', {}, '/foo/') - @item.reps << Nanoc::Int::ItemRep.new(@item, :default) - @item.reps[0].paths[:last] = '/foo/bar/' - - # Check - assert_equal('http://example.com/foo/bar/', feed_url) - ensure - # Cleanup - @item = nil - end - - def test_feed_url_with_custom_feed_url - # Create site - @config = Nanoc::ConfigView.new({ base_url: 'http://example.com' }) - - # Create feed item - @item = Nanoc::Int::Item.new('content', { feed_url: 'http://example.com/feed/' }, '/foo/') - @item.reps << Nanoc::Int::ItemRep.new(@item, :default) - @item.reps[0].paths[:last] = '/foo/bar/' - - # Check - assert_equal('http://example.com/feed/', feed_url) - ensure - # Cleanup - @item = nil - end - - def test_feed_url_without_base_url - # Create site - @config = Nanoc::ConfigView.new({}) - - # Check - assert_raises(Nanoc::Int::Errors::GenericTrivial) do - feed_url - end - end - - def test_atom_tag_for_with_path - # Create site - @config = Nanoc::ConfigView.new({ base_url: 'http://example.com' }) - - # Create article - item = Nanoc::Int::Item.new('content', { created_at: '2008-05-19' }, '/foo/') - item.reps << Nanoc::Int::ItemRep.new(item, :default) - item.reps[0].paths[:last] = '/foo/bar/' - - # Check - assert_equal('tag:example.com,2008-05-19:/foo/bar/', atom_tag_for(item)) - end - - def test_atom_tag_for_without_path - # Create site - @config = Nanoc::ConfigView.new({ base_url: 'http://example.com' }) - - # Create article - item = Nanoc::Int::Item.new('content', { created_at: '2008-05-19' }, '/baz/qux/') - item.reps << Nanoc::Int::ItemRep.new(item, :default) - - # Check - assert_equal('tag:example.com,2008-05-19:/baz/qux/', atom_tag_for(item)) - end - - def test_atom_tag_for_with_base_url_in_dir - # Create site - @config = Nanoc::ConfigView.new({ base_url: 'http://example.com/somedir' }) - - # Create article - item = Nanoc::Int::Item.new('content', { created_at: '2008-05-19' }, '/foo/') - item.reps << Nanoc::Int::ItemRep.new(item, :default) - item.reps[0].paths[:last] = '/foo/bar/' - - # Check - assert_equal('tag:example.com,2008-05-19:/somedir/foo/bar/', atom_tag_for(item)) - end - - def test_atom_tag_for_with_time - # Create site - @config = Nanoc::ConfigView.new({ base_url: 'http://example.com' }) - - # Create article - item = Nanoc::Int::Item.new('content', { created_at: Time.parse('2008-05-19') }, '/foo/') - item.reps << Nanoc::Int::ItemRep.new(item, :default) - item.reps[0].paths[:last] = '/foo/bar/' - - # Check - assert_equal('tag:example.com,2008-05-19:/foo/bar/', atom_tag_for(item)) - end - - def test_atom_tag_for_with_date - # Create site - @config = Nanoc::ConfigView.new({ base_url: 'http://example.com' }) - - # Create article - item = Nanoc::Int::Item.new('content', { created_at: Date.parse('2008-05-19') }, '/foo/') - item.reps << Nanoc::Int::ItemRep.new(item, :default) - item.reps[0].paths[:last] = '/foo/bar/' - - # Check - assert_equal('tag:example.com,2008-05-19:/foo/bar/', atom_tag_for(item)) end end