Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix comment parsing in Console lexer #1379

Merged
merged 4 commits into from
Dec 23, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add tests
  • Loading branch information
pyrmont committed Dec 17, 2019
commit e2b6fd920abebe80974efb3cc88c6c90da47b251
45 changes: 45 additions & 0 deletions spec/lexers/console_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,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