2015-12-16 00:07:31 -05:00
|
|
|
# frozen_string_literal: false
|
2013-02-24 08:10:46 -05:00
|
|
|
require_relative "rss-testcase"
|
2004-10-31 09:14:21 -05:00
|
|
|
|
|
|
|
require "rss/maker"
|
|
|
|
|
|
|
|
module RSS
|
|
|
|
class TestMakerXMLStyleSheet < TestCase
|
|
|
|
|
2004-11-03 01:43:18 -05:00
|
|
|
def test_xml_stylesheet
|
2004-10-31 09:14:21 -05:00
|
|
|
href = 'a.xsl'
|
|
|
|
type = 'text/xsl'
|
|
|
|
title = 'sample'
|
|
|
|
media = 'printer'
|
|
|
|
charset = 'UTF-8'
|
|
|
|
alternate = 'yes'
|
|
|
|
|
|
|
|
rss = RSS::Maker.make("1.0") do |maker|
|
2007-03-17 06:13:25 -04:00
|
|
|
maker.xml_stylesheets.new_xml_stylesheet do |xss|
|
|
|
|
xss.href = href
|
|
|
|
xss.type = type
|
|
|
|
xss.title = title
|
|
|
|
xss.media = media
|
|
|
|
xss.charset = charset
|
|
|
|
xss.alternate = alternate
|
|
|
|
end
|
|
|
|
|
2004-10-31 09:14:21 -05:00
|
|
|
setup_dummy_channel(maker)
|
2007-03-17 06:13:25 -04:00
|
|
|
setup_dummy_item(maker)
|
2004-10-31 09:14:21 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
xss = rss.xml_stylesheets.first
|
|
|
|
assert_equal(href, xss.href)
|
|
|
|
assert_equal(type, xss.type)
|
|
|
|
assert_equal(title, xss.title)
|
|
|
|
assert_equal(media, xss.media)
|
|
|
|
assert_equal(charset, xss.charset)
|
|
|
|
assert_equal(alternate, xss.alternate)
|
2004-11-01 08:30:08 -05:00
|
|
|
|
2009-03-05 22:56:38 -05:00
|
|
|
|
2004-11-01 08:30:08 -05:00
|
|
|
href = 'http://example.com/index.xsl'
|
|
|
|
type = 'text/xsl'
|
|
|
|
rss = RSS::Maker.make("1.0") do |maker|
|
2007-08-04 23:03:05 -04:00
|
|
|
maker.xml_stylesheets.new_xml_stylesheet do |_xss|
|
|
|
|
_xss.href = href
|
2007-03-17 06:13:25 -04:00
|
|
|
end
|
|
|
|
|
2004-11-01 08:30:08 -05:00
|
|
|
setup_dummy_channel(maker)
|
2007-03-17 06:13:25 -04:00
|
|
|
setup_dummy_item(maker)
|
2004-11-01 08:30:08 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
xss = rss.xml_stylesheets.first
|
|
|
|
assert_equal(href, xss.href)
|
|
|
|
assert_equal(type, xss.type)
|
2004-10-31 09:14:21 -05:00
|
|
|
end
|
2004-11-03 01:43:18 -05:00
|
|
|
|
|
|
|
def test_not_valid_xml_stylesheet
|
|
|
|
href = 'xss.XXX'
|
|
|
|
type = "text/xsl"
|
2009-03-05 22:56:38 -05:00
|
|
|
|
2004-11-03 01:43:18 -05:00
|
|
|
rss = RSS::Maker.make("1.0") do |maker|
|
2007-03-17 06:13:25 -04:00
|
|
|
maker.xml_stylesheets.new_xml_stylesheet do |xss|
|
|
|
|
# xss.href = href
|
|
|
|
xss.type = type
|
|
|
|
end
|
|
|
|
|
2004-11-03 01:43:18 -05:00
|
|
|
setup_dummy_channel(maker)
|
2007-03-17 06:13:25 -04:00
|
|
|
setup_dummy_item(maker)
|
2004-11-03 01:43:18 -05:00
|
|
|
end
|
|
|
|
assert(rss.xml_stylesheets.empty?)
|
|
|
|
|
|
|
|
rss = RSS::Maker.make("1.0") do |maker|
|
2007-03-17 06:13:25 -04:00
|
|
|
maker.xml_stylesheets.new_xml_stylesheet do |xss|
|
|
|
|
xss.href = href
|
|
|
|
# xss.type = type
|
|
|
|
end
|
|
|
|
|
2004-11-03 01:43:18 -05:00
|
|
|
setup_dummy_channel(maker)
|
2007-03-17 06:13:25 -04:00
|
|
|
setup_dummy_item(maker)
|
2004-11-03 01:43:18 -05:00
|
|
|
end
|
|
|
|
assert(rss.xml_stylesheets.empty?)
|
|
|
|
end
|
2009-03-05 22:56:38 -05:00
|
|
|
|
2004-10-31 09:14:21 -05:00
|
|
|
end
|
|
|
|
end
|