<commit_before>require File.dirname(__FILE__) + '/test_helper'

require 'cerberus/publisher/rss'
require 'mock/manager'
require 'tempfile'

class RSSPublisherTest < Test::Unit::TestCase
  def test_publisher
    rss_file = tf = Tempfile.new('cerberus-rss')
    options = Cerberus::Config.new(nil, :publisher => {:rss => {:file => rss_file.path}}, :application_name => 'RSSApp')
    build = DummyManager.new('last message', 'this is output', 1235, 'anatol')

    Cerberus::Publisher::RSS.publish(:setup, build, options)

    xml = REXML::Document.new(IO.read(rss_file.path))

    assert_equal '[RSSApp] Cerberus set up for project (#1235)', xml.elements["rss/channel/item/title/"].get_text.value
  end
  
  def test_publisher_xml_in_body_and_title
    rss_file = tf = Tempfile.new('cerberus-rss')
    options = Cerberus::Config.new(nil, :publisher => {:rss => {:file => rss_file.path}}, :application_name => 'RSS<App')
    build = DummyManager.new('last message', 'this is output', 1235, 'anatol')

    Cerberus::Publisher::RSS.publish(:setup, build, options)

    xml = REXML::Document.new(IO.read(rss_file.path))

    assert_equal '[RSS<App] Cerberus set up for project (#1235)', xml.elements["rss/channel/item/title/"].get_text.value
    assert_match %r{<pre>last message\n\nthis is output\n\n--\nCerberus 0.\d.\d, http://cerberus.rubyforge.com/</pre>}, xml.elements["rss/channel/item/description/"].get_text.value
  end
end<commit_msg>Simplify RSS test<commit_after>require File.dirname(__FILE__) + '/test_helper'

require 'cerberus/publisher/rss'
require 'mock/manager'
require 'tempfile'

class RSSPublisherTest < Test::Unit::TestCase
  def test_publisher
    rss_file = Tempfile.new('cerberus-rss')
    options = Cerberus::Config.new(nil, :publisher => {:rss => {:file => rss_file.path}}, :application_name => 'RSS<App')
    build = DummyManager.new('last message', 'this is output', 1235, 'anatol')

    Cerberus::Publisher::RSS.publish(:setup, build, options)

    xml = REXML::Document.new(IO.read(rss_file.path))

    assert_equal '[RSS<App] Cerberus set up for project (#1235)', xml.elements["rss/channel/item/title/"].get_text.value
    assert_match %r{<pre>last message\n\nthis is output\n\n--\nCerberus 0.\d.\d, http://cerberus.rubyforge.com/</pre>}, 
                     xml.elements["rss/channel/item/description/"].get_text.value
  end
end
{'fraction_non_alphanumeric': 0.16468590831918506, 'fraction_numerical': 0.011035653650254669, 'mean_word_length': 4.665865384615385, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 9}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7361233', 'n_tokens_mistral': 868, 'n_tokens_neox': 811, 'n_words': 150}