Sha256: bf3b8ad4602d2e386c98100f29335a538448573b6f7760411dbe56f44c61ddad

Contents?: true

Size: 1.63 KB

Versions: 2

Compression:

Stored size: 1.63 KB

Contents

require 'test_helper'

class BlockCutterTest < Test::Unit::TestCase
  context "basic behavior" do
    setup do
      @block_cutter = Flannel::BlockCutter.new
    end

    should "split a flannel document into blocks based on block_headers" do
      markup = ":paragraph bar\n some text\n:paragraph baz\n some more text"

      blocks = @block_cutter.cut markup
      assert_equal 2, blocks.length
 
      assert_equal :paragraph, blocks[0].type
      assert_equal "bar", blocks[0].id
      assert_equal :paragraph, blocks[1].type
      assert_equal "baz", blocks[1].id

    end

    should "not split preformatted text based on blank lines" do
      markup = ":preformatted my_preformatted\n foo\n\nbar\n"

      blocks = @block_cutter.cut markup
      assert_equal 1, blocks.length
      assert_equal :preformatted, blocks[0].type
      assert_equal "my_preformatted", blocks[0].id
      assert_equal " foo\n\nbar\n", blocks[0].text
    end


    should "separate preformatted blocks" do
      markup = ":preformatted one\nfoo\n:preformatted two\nbar\n"

      blocks = @block_cutter.cut markup
      assert_equal 2, blocks.length
      assert_equal :preformatted, blocks[0].type
      assert_equal :preformatted, blocks[1].type
    end

    should "strip preformatted markers when found" do
      markup = ":preformatted foo\nfoo\n\nbar\n"

      blocks = @block_cutter.cut markup
      assert_equal "foo\n\nbar\n",  blocks[0].text
    end
    
    should "set square style to feed based on full tag " do
      markup = ":feed wonki\nhttp://www.example.com/rss"

      blocks = @block_cutter.cut markup
      assert_equal :feed, blocks[0].type
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
flannel-0.2.10 test/block_cutter_test.rb
flannel-0.2.9 test/block_cutter_test.rb