File: formatter_spec.rb

package info (click to toggle)
ruby-rouge 4.7.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,844 kB
  • sloc: ruby: 38,489; sed: 2,071; perl: 152; makefile: 8
file content (35 lines) | stat: -rw-r--r-- 944 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# frozen_string_literal: true

describe Rouge::Formatter do
  it 'finds terminal256' do
    assert { Rouge::Formatter.find('terminal256') }
  end

  it 'is found by Rouge.highlight' do
    assert { Rouge.highlight('puts "Hello"', 'ruby', 'terminal256') }
  end

  it 'does not escape by default' do
    assert { not Rouge::Formatter.escape_enabled? }
  end

  it 'escapes in all threads with #enable_escape!' do
    begin
      Rouge::Formatter.enable_escape!
      assert { Rouge::Formatter.escape_enabled? }
    ensure
      Rouge::Formatter.disable_escape!
    end
  end

  it 'escapes locally with #with_escape' do
    Rouge::Formatter.with_escape do
      assert { Rouge::Formatter.escape_enabled? }
      assert { not Thread.new { Rouge::Formatter.escape_enabled? }.value }
      Rouge::Formatter.disable_escape!
      assert { not Rouge::Formatter.escape_enabled? }
    end

    assert { not Rouge::Formatter.escape_enabled? }
  end
end