mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-10-29 17:50:22 +00:00
Make Language methods more resilient to non-String input (#3752)
* Add failing test for finding with non-String input Show the failing behaviour of find_by_alias, find_by_name, and [] when non-String input is provided. * Return nil rather than erroring on non-String input
This commit is contained in:
@@ -270,6 +270,12 @@ class TestLanguage < Minitest::Test
|
||||
assert_nil Language[""]
|
||||
end
|
||||
|
||||
def test_does_not_blow_up_with_non_string_lookup
|
||||
assert_nil Language.find_by_alias(true)
|
||||
assert_nil Language.find_by_name(true)
|
||||
assert_nil Language[true]
|
||||
end
|
||||
|
||||
def test_name
|
||||
assert_equal 'Perl', Language['Perl'].name
|
||||
assert_equal 'Python', Language['Python'].name
|
||||
|
||||
Reference in New Issue
Block a user