Sha256: 343a97d7ccbd6116073f3bd320e00c2f0fbeb2142ac300483a56c167eb492b30

Contents?: true

Size: 1.04 KB

Versions: 16

Compression:

Stored size: 1.04 KB

Contents

require File.expand_path(File.join(File.dirname(__FILE__), "helper"))

class TestXsltTransforms < Nokogiri::TestCase
  def test_transform
    assert doc = Nokogiri::XML.parse(File.read(XML_FILE))
    assert doc.xml?

    assert style = Nokogiri::XSLT.parse(File.read(XSLT_FILE))

    assert result = style.apply_to(doc, ['title', '"Booyah"'])
    assert_match %r{<h1>Booyah</h1>}, result
    assert_match %r{<th.*Employee ID</th>}, result
    assert_match %r{<th.*Name</th>}, result
    assert_match %r{<th.*Position</th>}, result
    assert_match %r{<th.*Salary</th>}, result
    assert_match %r{<td>EMP0003</td>}, result
    assert_match %r{<td>Margaret Martin</td>}, result
    assert_match %r{<td>Computer Specialist</td>}, result
    assert_match %r{<td>100,000</td>}, result
    assert_no_match %r{Dallas|Texas}, result
    assert_no_match %r{Female}, result

    assert result = style.apply_to(doc, ['title', '"Grandma"'])
    assert_match %r{<h1>Grandma</h1>}, result

    assert result = style.apply_to(doc)
    assert_match %r{<h1></h1>}, result
  end
end

Version data entries

16 entries across 16 versions & 2 rubygems

Version Path
tenderlove-nokogiri-0.0.0-x86-mswin32-60 test/test_xslt_transforms.rb
tenderlove-nokogiri-0.0.0.20081001111445 test/test_xslt_transforms.rb
nokogiri-1.0.0 test/test_xslt_transforms.rb
nokogiri-1.0.0-x86-mswin32-60 test/test_xslt_transforms.rb
nokogiri-1.0.1 test/test_xslt_transforms.rb
nokogiri-1.0.5-x86-mswin32-60 test/test_xslt_transforms.rb
nokogiri-1.0.4-x86-mswin32-60 test/test_xslt_transforms.rb
nokogiri-1.0.4 test/test_xslt_transforms.rb
nokogiri-1.0.2 test/test_xslt_transforms.rb
nokogiri-1.0.3 test/test_xslt_transforms.rb
nokogiri-1.0.3-x86-mswin32-60 test/test_xslt_transforms.rb
nokogiri-1.0.6 test/test_xslt_transforms.rb
nokogiri-1.0.6-x86-mswin32-60 test/test_xslt_transforms.rb
nokogiri-1.0.5 test/test_xslt_transforms.rb
nokogiri-1.0.7 test/test_xslt_transforms.rb
nokogiri-1.0.7-x86-mswin32-60 test/test_xslt_transforms.rb