Sha256: 25ea3ab0bc22ff9faca9cae08cd7b7c15c948052ec92247b6d1c698fe76026de

Contents?: true

Size: 1.25 KB

Versions: 22

Compression:

Stored size: 1.25 KB

Contents

require 'helper'

class Nanoc::Filters::ColorizeSyntax::PygmentizeTest < Nanoc::TestCase
  def test_pygmentize
    if_have 'nokogiri' do
      skip_unless_have_command 'pygmentize'

      # Create filter
      filter = ::Nanoc::Filters::ColorizeSyntax.new

      # Get input and expected output
      input = '<pre title="moo"><code class="language-ruby"># comment</code></pre>'
      expected_output = '<pre title="moo"><code class="language-ruby"><span class="c1"># comment</span></code></pre>'

      # Run filter
      actual_output = filter.setup_and_run(input, colorizers: { ruby: :pygmentize })
      assert_equal(expected_output, actual_output)
    end
  end

  def test_colorize_syntax_with_default_colorizer
    skip_unless_have_command 'pygmentize'

    if_have 'nokogiri' do
      # Create filter
      filter = ::Nanoc::Filters::ColorizeSyntax.new

      # Get input and expected output
      input = '<pre><code class="language-ruby">puts "foo"</code></pre>'
      expected_output = '<pre><code class="language-ruby"><span class="nb">puts</span> <span class="s2">"foo"</span></code></pre>'

      # Run filter
      actual_output = filter.setup_and_run(input, default_colorizer: :pygmentize)
      assert_equal(expected_output, actual_output)
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
nanoc-4.7.9 test/filters/colorize_syntax/test_pygmentize.rb
nanoc-4.7.8 test/filters/colorize_syntax/test_pygmentize.rb
nanoc-4.7.7 test/filters/colorize_syntax/test_pygmentize.rb
nanoc-4.7.6 test/filters/colorize_syntax/test_pygmentize.rb
nanoc-4.7.5 test/filters/colorize_syntax/test_pygmentize.rb
nanoc-4.7.4 test/filters/colorize_syntax/test_pygmentize.rb
nanoc-4.7.3 test/filters/colorize_syntax/test_pygmentize.rb
nanoc-4.7.2 test/filters/colorize_syntax/test_pygmentize.rb
nanoc-4.7.1 test/filters/colorize_syntax/test_pygmentize.rb
nanoc-4.7.0 test/filters/colorize_syntax/test_pygmentize.rb
nanoc-4.6.4 test/filters/colorize_syntax/test_pygmentize.rb
nanoc-4.6.3 test/filters/colorize_syntax/test_pygmentize.rb
nanoc-4.6.2 test/filters/colorize_syntax/test_pygmentize.rb
nanoc-4.6.1 test/filters/colorize_syntax/test_pygmentize.rb
nanoc-4.6.0 test/filters/colorize_syntax/test_pygmentize.rb
nanoc-4.5.4 test/filters/colorize_syntax/test_pygmentize.rb
nanoc-4.5.3 test/filters/colorize_syntax/test_pygmentize.rb
nanoc-4.5.2 test/filters/colorize_syntax/test_pygmentize.rb
nanoc-4.5.1 test/filters/colorize_syntax/test_pygmentize.rb
nanoc-4.5.0 test/filters/colorize_syntax/test_pygmentize.rb