-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathcommand_parser_test.rb
47 lines (33 loc) · 1.5 KB
/
command_parser_test.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
require 'minitest/autorun'
require_relative 'command_parser'
class CommandParserTest < Minitest::Test
def test_returns_parsed_command_when_main_command_of_raw_command_is_present_in_whitelist
parser = CommandParser.new(whitelist: [:fiz])
assert_equal [:fiz], parser.call('fiz')
end
def test_returns_parsed_command_when_raw_command_matches_whitelist_but_has_spaces
parser = CommandParser.new(whitelist: [:fez_cafe])
assert_equal [:fez_cafe], parser.call('fez cafe')
end
def test_returns_parsed_command_when_raw_command_matches_whitelist_but_has_dashes
parser = CommandParser.new(whitelist: [:fez_cafe])
assert_equal [:fez_cafe], parser.call('fez-cafe')
end
def test_returns_parsed_command_when_main_command_of_raw_command_has_question_mark
parser = CommandParser.new(whitelist: [:fez?])
assert_equal [:fez?], parser.call('fez?')
end
def test_returns_parsed_command_with_arguments_when_raw_command_has_arguments
parser = CommandParser.new(whitelist: [:quem_faz])
assert_equal [:quem_faz, 'joao, maria'], parser.call('quem faz joao, maria')
end
def test_does_not_return_parsed_command_when_main_command_of_raw_command_is_not_at_the_start
parser = CommandParser.new(whitelist: [:fiz])
assert_nil parser.call('fez fiz')
assert_nil parser.call('ffiz')
end
def test_does_not_return_parsed_command_when_main_command_of_raw_command_is_not_present_in_whitelist
parser = CommandParser.new(whitelist: [:fez])
assert_nil parser.call('fiz')
end
end