<commit_before>(ns bløggr.rss-test
  (:use midje.sweet)
  (:require [bløggr.rss :refer :all]
            [clj-time.core :as time]))

(def settings
  {:site-title "abc"
   :site-description "def"
   :base-url "http://url.com"
   :author "ghij"})

(def posts
  [{:header {:title "Post A title"
             :slug "post_a_title"
             :date (time/date-time 2000 1 2 3 4 5 6)}
    :rss-content "Post A content"}])

(fact "get-rss renders xml with site details"
  (let [rss (get-rss settings [])]
    rss => (contains "<title>\nabc\n</title>")
    rss => (contains "<link>\nhttp://url.com\n</link>")
    rss => (contains "<description>\ndef\n</description>")))

(fact "get-rss renders xml with posts"
  (let [rss (get-rss settings posts)]
    rss => (contains "<title>\nPost A title\n</title>")
    rss => (contains "<description>\nPost A content\n</description>")
    rss => (contains "<pubDate>\nSun, 02 Jan 2000 04:04:05 +0100\n</pubDate>")
    rss => (contains "<link>\nhttp://url.com/2000/01/02/post_a_title/\n</link>")))

(fact "get-rss should change relative image paths to absolute paths"
  (get-rss settings [(assoc (first posts) :rss-content "<img src=\"/images/blah.jpg\">")]) =>
  (contains "http://url.com/images/blah.jpg"))<commit_msg>locale broke rss date check<commit_after>(ns bløggr.rss-test
  (:use midje.sweet)
  (:require [bløggr.rss :refer :all]
            [clj-time.core :as time]))

(def settings
  {:site-title "abc"
   :site-description "def"
   :base-url "http://url.com"
   :author "ghij"})

(def posts
  [{:header {:title "Post A title"
             :slug "post_a_title"
             :date (time/date-time 2000 1 2 3 4 5 6)}
    :rss-content "Post A content"}])

(fact "get-rss renders xml with site details"
  (let [rss (get-rss settings [])]
    rss => (contains "<title>\nabc\n</title>")
    rss => (contains "<link>\nhttp://url.com\n</link>")
    rss => (contains "<description>\ndef\n</description>")))

(fact "get-rss renders xml with posts"
  (let [rss (get-rss settings posts)]
    rss => (contains "<title>\nPost A title\n</title>")
    rss => (contains "<description>\nPost A content\n</description>")
    rss => (contains "<pubDate>")
    rss => (contains "<link>\nhttp://url.com/2000/01/02/post_a_title/\n</link>")))

(fact "get-rss should change relative image paths to absolute paths"
  (get-rss settings [(assoc (first posts) :rss-content "<img src=\"/images/blah.jpg\">")]) =>
  (contains "http://url.com/images/blah.jpg"))
{'fraction_non_alphanumeric': 0.1954674220963173, 'fraction_numerical': 0.02104411169566977, 'mean_word_length': 3.3141361256544504, 'pattern_counts': {'":': 0, '<': 32, '<?xml version=': 0, '>': 48, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, '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': '3188641', 'n_tokens_mistral': 924, 'n_tokens_neox': 862, 'n_words': 228}