-
Notifications
You must be signed in to change notification settings - Fork 740
/
console_spec.rb
45 lines (37 loc) · 1.15 KB
/
console_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
36
37
38
39
40
41
42
43
44
45
# -*- coding: utf-8 -*- #
# frozen_string_literal: true
describe Rouge::Lexers::ConsoleLexer do
let(:subject) { Rouge::Lexers::ConsoleLexer.new }
let(:klass) { Rouge::Lexers::ConsoleLexer }
include Support::Lexing
it 'parses a basic prompt' do
assert_tokens_equal '$ foo',
['Generic.Prompt', '$'],
['Text.Whitespace', ' '],
['Text', 'foo']
end
it 'parses a custom prompt' do
subject_with_options = klass.new({ prompt: '%' })
assert_tokens_equal '% foo', subject_with_options,
['Generic.Prompt', '%'],
['Text.Whitespace', ' '],
['Text', 'foo']
end
it 'parses single-line comments' do
subject_with_options = klass.new({ comments: true })
assert_tokens_equal '# this is a comment', subject_with_options,
['Comment', '# this is a comment']
end
it 'ignores single-line comments' do
assert_tokens_equal '# this is not a comment',
['Generic.Prompt', '#'],
['Text.Whitespace', ' '],
['Text', 'this is not a comment']
end
describe 'guessing' do
include Support::Guessing
it 'guesses by filename' do
assert_guess :filename => 'foo.cap'
end
end
end