forked from rouge-ruby/rouge
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcli_spec.rb
70 lines (57 loc) · 1.74 KB
/
cli_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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# -*- coding: utf-8 -*- #
require 'rouge/cli'
describe Rouge::CLI do
let(:argv) { [] }
subject { Rouge::CLI.parse(argv) }
describe Rouge::CLI::Help do
describe '-h' do
let(:argv) { %w(-h) }
it('parses') { assert { Rouge::CLI::Help === subject } }
end
describe '--help' do
let(:argv) { %w(--help) }
it('parses') { assert { Rouge::CLI::Help === subject } }
end
describe 'help' do
let(:argv) { %w(help) }
it('parses') { assert { Rouge::CLI::Help === subject } }
end
describe 'nil' do
let(:argv) { %w() }
it('parses') { assert { Rouge::CLI::Help === subject } }
end
end
describe Rouge::CLI::Highlight do
describe 'specifying a lexer' do
let(:argv) { %w(highlight -l ruby) }
it('parses') {
assert { Rouge::CLI::Highlight === subject }
assert { Rouge::Lexers::Ruby === subject.lexer }
}
end
describe 'guessing a lexer by mimetype' do
let(:argv) { %w(highlight -m application/javascript) }
it('parses') {
assert { Rouge::Lexers::Javascript === subject.lexer }
}
end
describe 'guessing a lexer by file contents' do
let(:argv) { %w(highlight -i bin/rougify) }
it('parses') {
assert { Rouge::Lexers::Ruby === subject.lexer }
}
end
end
describe Rouge::CLI::List do
describe 'list' do
let(:argv) { %w(list) }
it('parses') { assert { Rouge::CLI::List === subject } }
it 'lists available lexers' do
out, err = capture_io { subject.run }
expected_tags = Rouge::Lexer.all.map(&:tag).sort
actual_tags = out.scan(/^([^\s]*?):/).flatten
assert_equal expected_tags, actual_tags, "err: #{err.inspect}"
end
end
end
end