Sha256: 076767869fd6c34529cd073453ebe8506f530a7329b12c2dd8893d4572c47111

Contents?: true

Size: 1.16 KB

Versions: 2

Compression:

Stored size: 1.16 KB

Contents

# encoding: utf-8

class Nanoc::Filters::CodeRayTest < MiniTest::Unit::TestCase

  include Nanoc::TestHelpers

  def test_filter_without_language
    if_have 'coderay' do
      # Get filter
      filter = ::Nanoc::Filters::CodeRay.new

      # Run filter
      code = "def some_function ; x = blah.foo ; x.bar 'xyzzy' ; end"
      assert_raises(ArgumentError) do
        filter.setup_and_run(code)
      end
    end
  end

  def test_filter_with_known_language
    if_have 'coderay' do
      # Get filter
      filter = ::Nanoc::Filters::CodeRay.new

      # Run filter
      code = "def some_function ; x = blah.foo ; x.bar 'xyzzy' ; end"
      result = filter.setup_and_run(code, :language => 'ruby')
      assert_match %r{^<span class="keyword">def</span> <span class="function">some_function</span>}, result
    end
  end

  def test_filter_with_unknown_language
    if_have 'coderay' do
      # Get filter
      filter = ::Nanoc::Filters::CodeRay.new

      # Run filter
      code = "def some_function ; x = blah.foo ; x.bar 'xyzzy' ; end"
      result = filter.setup_and_run(code, :language => 'skldfhjsdhfjszfnocmluhfixfmersumulh')
      assert_equal code, result
    end
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
nanoc-3.6.1 test/filters/test_coderay.rb
nanoc-3.6.0 test/filters/test_coderay.rb