-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
require 'test_helper' | ||
require 'changit/lexer' | ||
require 'changit/lexer/section_token' | ||
|
||
class LexerTest < Minitest::Test | ||
def test_tokenize | ||
tokens = lexer.tokens | ||
|
||
assert_kind_of Array, tokens | ||
refute_empty tokens | ||
assert_equal tokens.size, lexer.original_expression.each_line.count | ||
end | ||
|
||
def test_to_hash | ||
token_hash = lexer.token_hash | ||
|
||
assert_kind_of Hash, token_hash | ||
refute_empty token_hash | ||
assert_kind_of_array Changit::Lexer::SectionToken, token_hash.keys | ||
end | ||
|
||
private | ||
|
||
def lexer | ||
config = "[user]\n\tname = testname\n\temail = [email protected]\n[core]\n\teditor = vim\n[color]\n\tui = true\n[rebase]\n\tautosquash = true\n".freeze | ||
Changit::Lexer.new(config) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,11 @@ | ||
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__) | ||
|
||
require 'minitest/autorun' | ||
|
||
# some unorganized helpers | ||
|
||
def assert_kind_of_array(kind, arr) | ||
arr.all? do |e| | ||
assert_kind_of kind, e | ||
end | ||
end |