Skip to content
This repository has been archived by the owner on May 1, 2021. It is now read-only.

Commit

Permalink
added more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
subosito committed Jul 4, 2019
1 parent 200b4df commit 9cb6561
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
2 changes: 0 additions & 2 deletions lib/gingerice/command.rb
Expand Up @@ -69,8 +69,6 @@ def parse_args
options[:output] = :verbose
when 'count'
options[:output] = :count
else
options[:output] = :simple
end
end

Expand Down
18 changes: 18 additions & 0 deletions test/test_gingerice.rb
Expand Up @@ -77,6 +77,14 @@ def test_command_simple_output_cryptic
assert_equal ": \n", output.string
end

def test_command_verbose_output_deprecated
output = capture_stdout do
command = Gingerice::Command.new(["--verbose", "He flyed to Jakarta"])
command.execute
end
assert_match 'corrections', output.string
end

def test_command_verbose_output
output = capture_stdout do
command = Gingerice::Command.new(["--output", "verbose", "He flyed to Jakarta"])
Expand Down Expand Up @@ -150,5 +158,15 @@ def test_parse_error_exceptions
exception = assert_raise(Gingerice::ParseError) { invalid_parser.parse('Hllo') }
assert_equal 'ERROR: We receive invalid JSON format!', exception.message
end

def test_parse_error_exceptions_output_count
invalid_parser = Gingerice::Parser.new({
api_endpoint: 'https://subosito.com/',
output: :count
})

exception = assert_raise(Gingerice::ParseError) { invalid_parser.parse('Hllo') }
assert_equal 'ERROR: We receive invalid JSON format!', exception.message
end
end

0 comments on commit 9cb6561

Please sign in to comment.