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