Sha256: 89d2e60b8980ee132178d301a36ab68d6b28d066b7e8a1d7a8e514b9a5b49c82

Contents?: true

Size: 1.13 KB

Versions: 15

Compression:

Stored size: 1.13 KB

Contents

# encoding: utf-8

class Nanoc::Filters::CodeRayTest < Nanoc::TestCase

  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

15 entries across 15 versions & 1 rubygems

Version Path
nanoc-3.7.4 test/filters/test_coderay.rb
nanoc-3.7.3 test/filters/test_coderay.rb
nanoc-3.7.2 test/filters/test_coderay.rb
nanoc-3.7.1 test/filters/test_coderay.rb
nanoc-3.7.0 test/filters/test_coderay.rb
nanoc-3.6.11 test/filters/test_coderay.rb
nanoc-3.6.10 test/filters/test_coderay.rb
nanoc-3.6.9 test/filters/test_coderay.rb
nanoc-3.6.8 test/filters/test_coderay.rb
nanoc-3.6.7 test/filters/test_coderay.rb
nanoc-3.6.6 test/filters/test_coderay.rb
nanoc-3.6.5 test/filters/test_coderay.rb
nanoc-3.6.4 test/filters/test_coderay.rb
nanoc-3.6.3 test/filters/test_coderay.rb
nanoc-3.6.2 test/filters/test_coderay.rb