test/helpers/test_blogging.rb in nanoc-3.4.3 vs test/helpers/test_blogging.rb in nanoc-3.5.0b1
- old
+ new
@@ -172,11 +172,11 @@
@item.stubs(:[]).with(:title).returns('My Blog Or Something')
@item.stubs(:[]).with(:author_name).returns('J. Doe')
@item.stubs(:[]).with(:author_uri).returns('http://example.com/~jdoe')
# Check
- error = assert_raises(RuntimeError) do
+ error = assert_raises(Nanoc::Errors::GenericTrivial) do
atom_feed
end
assert_equal(
'Cannot build Atom feed: no articles',
error.message
@@ -198,11 +198,11 @@
@item.stubs(:[]).with(:title).returns('My Blog Or Something')
@item.stubs(:[]).with(:author_name).returns('J. Doe')
@item.stubs(:[]).with(:author_uri).returns('http://example.com/~jdoe')
# Check
- error = assert_raises(RuntimeError) do
+ error = assert_raises(Nanoc::Errors::GenericTrivial) do
atom_feed
end
assert_equal(
'Cannot build Atom feed: site configuration has no base_url',
error.message
@@ -224,11 +224,11 @@
@item.stubs(:[]).with(:title).returns(nil)
@item.stubs(:[]).with(:author_name).returns('J. Doe')
@item.stubs(:[]).with(:author_uri).returns('http://example.com/~jdoe')
# Check
- error = assert_raises(RuntimeError) do
+ error = assert_raises(Nanoc::Errors::GenericTrivial) do
atom_feed
end
assert_equal(
'Cannot build Atom feed: no title in params, item or site config',
error.message
@@ -250,11 +250,11 @@
@item.stubs(:[]).with(:title).returns('My Blog Or Something')
@item.stubs(:[]).with(:author_name).returns(nil)
@item.stubs(:[]).with(:author_uri).returns('http://example.com/~jdoe')
# Check
- error = assert_raises(RuntimeError) do
+ error = assert_raises(Nanoc::Errors::GenericTrivial) do
atom_feed
end
assert_equal(
'Cannot build Atom feed: no author_name in params, item or site config',
error.message
@@ -324,11 +324,11 @@
@item.stubs(:[]).with(:title).returns('My Blog Or Something')
@item.stubs(:[]).with(:author_name).returns('J. Doe')
@item.stubs(:[]).with(:author_uri).returns(nil)
# Check
- error = assert_raises(RuntimeError) do
+ error = assert_raises(Nanoc::Errors::GenericTrivial) do
atom_feed
end
assert_equal(
'Cannot build Atom feed: no author_uri in params, item or site config',
error.message
@@ -352,11 +352,11 @@
@item.stubs(:[]).with(:title).returns('My Blog Or Something')
@item.stubs(:[]).with(:author_name).returns('J. Doe')
@item.stubs(:[]).with(:author_uri).returns('http://example.com/~jdoe')
# Check
- error = assert_raises(RuntimeError) do
+ error = assert_raises(Nanoc::Errors::GenericTrivial) do
atom_feed
end
assert_equal(
'Cannot build Atom feed: one or more articles lack created_at',
error.message
@@ -548,10 +548,54 @@
result = atom_feed :excerpt_proc => lambda { |a| 'foobar!' }
assert_match 'foobar!</summary>', result
end
end
+ def test_atom_feed_with_icon_param
+ if_have 'builder' do
+ # Mock article
+ @items = [ mock_article ]
+
+ # Mock site
+ @site = mock
+ @site.stubs(:config).returns({ :base_url => 'http://example.com' })
+
+ # Create feed item
+ @item = mock
+ @item.stubs(:[]).with(:title).returns('My Blog Or Something')
+ @item.stubs(:[]).with(:author_name).returns('J. Doe')
+ @item.stubs(:[]).with(:author_uri).returns('http://example.com/~jdoe')
+ @item.stubs(:[]).with(:feed_url).returns('http://example.com/feed')
+
+ # Check
+ result = atom_feed :icon => 'http://example.com/icon.png'
+ assert_match '<icon>http://example.com/icon.png</icon>', result
+ end
+ end
+
+ def test_atom_feed_with_logo_param
+ if_have 'builder' do
+ # Mock article
+ @items = [ mock_article ]
+
+ # Mock site
+ @site = mock
+ @site.stubs(:config).returns({ :base_url => 'http://example.com' })
+
+ # Create feed item
+ @item = mock
+ @item.stubs(:[]).with(:title).returns('My Blog Or Something')
+ @item.stubs(:[]).with(:author_name).returns('J. Doe')
+ @item.stubs(:[]).with(:author_uri).returns('http://example.com/~jdoe')
+ @item.stubs(:[]).with(:feed_url).returns('http://example.com/feed')
+
+ # Check
+ result = atom_feed :logo => 'http://example.com/logo.png'
+ assert_match '<logo>http://example.com/logo.png</logo>', result
+ end
+ end
+
def test_atom_feed_with_item_without_path
if_have 'builder' do
# Create items
@items = [ mock_article ]
@items[0].stubs(:path).returns(nil)
@@ -625,11 +669,11 @@
def test_url_for_without_base_url
# Create site
@site = Nanoc::Site.new({})
# Check
- assert_raises(RuntimeError) do
+ assert_raises(Nanoc::Errors::GenericTrivial) do
url_for(nil)
end
end
def test_url_for_without_path
@@ -680,10 +724,10 @@
def test_feed_url_without_base_url
# Create site
@site = Nanoc::Site.new({})
# Check
- assert_raises(RuntimeError) do
+ assert_raises(Nanoc::Errors::GenericTrivial) do
feed_url
end
end
def test_atom_tag_for_with_path