# encoding: utf-8 require 'tempfile' class Nanoc::Filters::XSLTest < MiniTest::Unit::TestCase include Nanoc::TestHelpers SAMPLE_XSL = <<-EOS <xsl:value-of select="report/title"/>

EOS SAMPLE_XML_IN = <<-EOS My Report EOS SAMPLE_XML_OUT = <<-EOS My Report

My Report

EOS SAMPLE_XSL_WITH_PARAMS = <<-EOS <xsl:value-of select="$foo"/>

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) 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) result = filter.run(SAMPLE_XML_IN_WITH_PARAMS, :foo => 'bar') assert_equal SAMPLE_XML_OUT_WITH_PARAMS, result end end end