mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-10-29 09:40:21 +00:00
Raise an error is Language#name is missing
This commit is contained in:
@@ -43,7 +43,7 @@ module Linguist
|
||||
attr_reader :name, :extensions
|
||||
|
||||
def initialize(attributes = {})
|
||||
@name = attributes[:name]
|
||||
@name = attributes[:name] || raise(ArgumentError, "missing name")
|
||||
@extensions = attributes[:extensions] || []
|
||||
end
|
||||
end
|
||||
|
||||
@@ -32,6 +32,12 @@ class TestLanguage < Test::Unit::TestCase
|
||||
assert_equal "Ruby", Language['Ruby'].name
|
||||
end
|
||||
|
||||
def test_error_without_name
|
||||
assert_raise ArgumentError do
|
||||
Language.new :name => nil
|
||||
end
|
||||
end
|
||||
|
||||
def test_extensions
|
||||
assert Language['Perl'].extensions.include?('.pl')
|
||||
assert Language['Python'].extensions.include?('.py')
|
||||
|
||||
Reference in New Issue
Block a user