Sha256: 561f57a6406ba53d9aa6a4fee1798d93a0c617e541e35b18df2d5b96a650422b

Contents?: true

Size: 1.74 KB

Versions: 1

Compression:

Stored size: 1.74 KB

Contents

require 'spec_helper'

describe TodoNext::Tree do

  describe '#prune_example_nodes!' do

    specify 'an top-level example line with a sibling is removed' do
      source = 'spec 1'                 + "\n" +
               'example : ignore me'    + "\n" +
               'spec 2'
      tree = TodoNext::Parser.parse(source, prune_example_nodes=false)
      tree.to_hash[:children].should ==
                [  {:type  => :li, :text  => 'spec 1'             },
                   {:type  => :ex, :text  => 'example : ignore me', :children => []},
                   {:type  => :li, :text  => 'spec 2'             }
                ]
      tree = TodoNext::Parser.parse(source)
      tree.to_hash[:children].should ==
                [  {:type  => :li, :text  => 'spec 1', },
                   {:type  => :li, :text  => 'spec 2'}
                ]
    end

    specify 'an sb-level example line with a sibling is removed'


    specify 'an example block is removed' do
      source = 'HEADER 1'            + "\n" +
                '  ex :'              + "\n" +
                '    blabla'          + "\n" +
                '  spec b'

      tree = TodoNext::Parser.parse(source)
      tree.to_hash[:children].should ==
                [  {:type     => :ol , :text  => "HEADER 1",
                    :children => [{:type => :li, :text => "spec b"}]
                   }
                 ]
    end

    specify 'when an OL only child is an EX, it becomes a LI after pruning' do
      source = 'spec 1'               + "\n" +
                '  ex :'              + "\n" +
                '    blabla'

      tree = TodoNext::Parser.parse(source)
      tree.to_hash[:children].should ==
                [  {:type     => :li , :text  => "spec 1"}
                ]
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
todo_next-0.0.2 spec/tree_spec.rb