cirandas.net

ref: master

test/unit/feed_writer_test.rb


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
require_relative "../test_helper"

class FeedWriterTest < ActiveSupport::TestCase

  should 'generate feeds' do
    articles = []
    profile = fast_create(:profile, :identifier => "tagger")
    articles << fast_create(:article, :name => 'text 1', :slug => 'text-1', :path => 'text-1', :profile_id => profile.id)
    articles << fast_create(:article, :name => 'text 2', :slug => 'text-2', :path => 'text-2', :profile_id => profile.id) 
    writer = FeedWriter.new

    feed = writer.write(articles)
    assert_match('text 1', feed)
    assert_match('/tagger/' + articles.first.slug, feed)
  end

  should 'generate feed with a gallery' do
    articles = []
    profile = fast_create(:profile, :identifier => "tagger")
    articles << fast_create(:gallery, :name => 'my pics', :profile_id => profile.id)
    writer = FeedWriter.new

    feed = writer.write(articles)
    assert_match('my pics', feed)
  end

  should 'use title, link and description' do
    writer = FeedWriter.new
    rss = writer.write([], :title => "my title", :description => "my description", :link => "http://example.com/")
    assert_match("my title", rss)
    assert_match("my description", rss)
    assert_match("http://example.com/", rss)
  end

end