forked from rouge-ruby/rouge
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathformatter_spec.rb
35 lines (29 loc) · 944 Bytes
/
formatter_spec.rb
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