Sha256: 16b3ffeaa0393c03f698222de7d91e6b0153e6f3bb05abca410789e396614e82

Contents?: true

Size: 1.79 KB

Versions: 1

Compression:

Stored size: 1.79 KB

Contents

#  _____         _
# |_   _|__  ___| |_
#   | |/ _ \/ __| __|
#   | |  __/\__ \ |_
#   |_|\___||___/\__|
#
# for lib/facet/tagiterator.rb
#
# Extracted Wed Jan 25 10:52:52 EST 2006
# Unit Tools Reap Test Extractor
#

require 'facet/tagiterator.rb'


require 'test/unit'

class TC_TagIterator < Test::Unit::TestCase

  STEXT = <<-EOS
  <body> This is a test...
    <sub> S1 </sub> <sub> S2 </sub>
    <DL>
      <DT> A1
      <DT> A2
      <DT> A3
    </DL>
    <DL>
      <DT> B1
      <DT> B2
      <DT> B3
    </DL>
    <NEST>
      <P ALIGN="R">TOP</P>
      <NEST>
        <P>SECOND</P>
        <OL>
          <LI>C1
          <LI>C2
          <LI>C3
          <LI>C4
        </OL>
      </NEST>
      <OL>
        <LI>D1
        <LI>D2
        <LI>D3
        <LI>D4
      </OL>
    </NEST>
  </body>
  EOS

  def test_all
    assert_nothing_raised{ @a = TagIterator.new( STEXT ) }
    @f = []
    assert_nothing_raised {
      @a.first("body") do |y|
        y.nth("dl",2) do |dl|
          dl.enumtag("dt") do |t|
            @f << t.text.strip
          end
        end
        y.first("nest") do |n|
          n.first("p") do |c|
            @f << c.text
            @f.concat c.attributes.collect{ |k,v| "#{k}=#{v}" }
          end.next("nest") do |m|
            m.first("p") do |c|
              @f << c.text
            end.next("ol") do |o|
              o.enumtag("li") do |i| @f << i.text.strip end
            end
          end.next("ol") do |o|
            o.enumtag("li") do |i| @f << i.text.strip end
          end
        end
      end
      @a.each_block("sub") do |y|
        @f << y.text.strip
      end
    }
    o = [ "B1", "B2", "B3",
          "TOP", "align=R", "SECOND",
          "C1", "C2", "C3", "C4",
          "D1", "D2", "D3", "D4",
          "S1", "S2" ]
    assert_equal( o, @f )
  end

end


Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
facets-1.0.3 packages/more/test/lib/facet/test_tagiterator.rb