# encoding: utf-8
require 'tempfile'
class Nanoc::Filters::XSLTest < MiniTest::Unit::TestCase
include Nanoc::TestHelpers
SAMPLE_XSL = <<-EOS
EOS
SAMPLE_XML_IN = <<-EOS
My Report
EOS
SAMPLE_XML_OUT = <<-EOS
My Report
My Report
EOS
SAMPLE_XSL_WITH_PARAMS = <<-EOS
EOS
SAMPLE_XML_IN_WITH_PARAMS = <<-EOS
My Report
EOS
SAMPLE_XML_OUT_WITH_PARAMS = <<-EOS
bar
bar
EOS
def test_filter_as_layout
if_have 'nokogiri' do
layout = Nanoc::Layout.new(SAMPLE_XSL, {}, '/layout/')
filter = ::Nanoc::Filters::XSL.new(
:layout => layout, :content => SAMPLE_XSL)
result = filter.run(SAMPLE_XML_IN)
assert_equal SAMPLE_XML_OUT, result
end
end
def test_filter_with_params
if_have 'nokogiri' do
layout = Nanoc::Layout.new(SAMPLE_XSL_WITH_PARAMS, {}, '/layout/')
filter = ::Nanoc::Filters::XSL.new(
:layout => layout, :content => SAMPLE_XSL_WITH_PARAMS)
result = filter.run(SAMPLE_XML_IN_WITH_PARAMS, :foo => 'bar')
assert_equal SAMPLE_XML_OUT_WITH_PARAMS, result
end
end
end