Sha256: 20573bc18f61e8b7353c614830a68bb155b537be83535fb8bfa7c128099eb273

Contents?: true

Size: 1.93 KB

Versions: 24

Compression:

Stored size: 1.93 KB

Contents

require File.dirname(__FILE__) + '/../test_helper'

require 'erb'
require 'liquid'

require 'text_filters'
# require 'comatose/page'
# require 'comatose/processing_context'

class TextFiltersTest < Test::Unit::TestCase
  # fixtures :comatose_pages
  # self.use_instantiated_fixtures  = true

  should "not alter output when using filter :none" do
    assert_equal "line one\nline two", TextFilters.render_text("line one\nline two", :none)
  end

  should "convert newlines into <br/>s when using :simple filter" do
    assert_equal "line one<br/>line two", TextFilters.render_text("line one\nline two", :simple)
  end

  should "support Textile, if it's available, using :textile or 'Textile' as a key" do
    if TextFilters.all.keys.include? 'Textile'
      assert_equal "<p>testing <strong>bold</strong></p>", TextFilters.render_text("testing *bold*", :textile)
      assert_equal "<p>testing <strong>bold</strong></p>", TextFilters.render_text("testing *bold*", 'Textile')
    end
  end
  
  should "support Markdown, if it's available, using :markdown or 'Markdown' as a key" do
    if TextFilters.all.keys.include? 'Markdown'
      assert_equal "<p>testing <em>bold</em></p>", TextFilters.render_text("testing *bold*", :markdown)
    end
  end

  should "support RDoc, if it's available, using :rdoc or 'RDoc' as a key" do
    if TextFilters.all.keys.include? 'RDoc'
      assert_equal "<p>\ntesting <b>bold</b>\n</p>\n", TextFilters.render_text("testing *bold*", :rdoc)
      assert_equal "<p>\ntesting <b>bold</b>\n</p>\n", TextFilters.render_text("testing *bold*", 'RDoc')
    end
  end

  should "support transformation of parameters via ERB" do
    src = 'Hello, <%= name %>'
    assert_equal "Hello, Matt", TextFilters.transform(src, {'name'=>'Matt'}, :none, :erb)
  end

  should "support transformation of parameters via Liquid" do
    src = 'Hello, {{ name }}'
    assert_equal "Hello, Matt", TextFilters.transform(src, {'name'=>'Matt'}, :none, :liquid)
  end
  
end

Version data entries

24 entries across 24 versions & 7 rubygems

Version Path
aslakjo-aslakjo-comatose-2.0.5.1 test/unit/text_filters_test.rb
aslakjo-comatose-2.0.5.2 test/unit/text_filters_test.rb
aslakjo-comatose-2.0.5.3 test/unit/text_filters_test.rb
darthapo-comatose-2.0.3 test/unit/text_filters_test.rb
darthapo-comatose-2.0.4 test/unit/text_filters_test.rb
darthapo-comatose-2.0.5 test/unit/text_filters_test.rb
darthapo-comatose-2.0 test/unit/text_filters_test.rb
jcnetdev-comatose-2.0.1 test/unit/text_filters_test.rb
staugaard-comatose-2.0.2 test/unit/text_filters_test.rb
staugaard-comatose-2.0.3 test/unit/text_filters_test.rb
comatose-rubyisbeautiful-3.0.5 test/unit/text_filters_test.rb
comatose-rubyisbeautiful-3.0.4 test/unit/text_filters_test.rb
comatose-rubyisbeautiful-3.0.3 test/unit/text_filters_test.rb
comatose-rubyisbeautiful-3.0.2 test/unit/text_filters_test.rb
comatose-rubyisbeautiful-3.0.1 test/unit/text_filters_test.rb
comatose-rubyisbeautiful-3.0.0 test/unit/text_filters_test.rb
comatose-2.0.5 test/unit/text_filters_test.rb
comatose-2.0.1 test/unit/text_filters_test.rb
aslakjo-comatose-2.0.5.12 test/unit/text_filters_test.rb
aslakjo-comatose-2.0.5.11 test/unit/text_filters_test.rb