Sha256: 6e72d212f12c70b1d66f6d33383e6130c0e938707e9bc75ac0aa81e5b7f7b260

Contents?: true

Size: 1.13 KB

Versions: 15

Compression:

Stored size: 1.13 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.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.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.run(code, :language => 'skldfhjsdhfjszfnocmluhfixfmersumulh')
      assert_equal code, result
    end
  end

end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
nanoc-3.5.0 test/filters/test_coderay.rb
nanoc-3.5.0b2 test/filters/test_coderay.rb
nanoc-3.5.0b1 test/filters/test_coderay.rb
nanoc-3.4.3 test/filters/test_coderay.rb
nanoc-3.4.2 test/filters/test_coderay.rb
nanoc-3.4.1 test/filters/test_coderay.rb
nanoc-3.4.0 test/filters/test_coderay.rb
nanoc-3.3.7 test/filters/test_coderay.rb
nanoc-3.3.6 test/filters/test_coderay.rb
nanoc-3.3.5 test/filters/test_coderay.rb
nanoc-3.3.4 test/filters/test_coderay.rb
nanoc-3.3.3 test/filters/test_coderay.rb
nanoc-3.3.2 test/filters/test_coderay.rb
nanoc-3.3.1 test/filters/test_coderay.rb
nanoc-3.3.0 test/filters/test_coderay.rb