test/test_iso_639.rb in iso-639-0.3.5 vs test/test_iso_639.rb in iso-639-0.3.6
- old
+ new
@@ -10,22 +10,31 @@
it 'should have shorter code list in ISO_639_1' do
assert_equal 184, ISO_639::ISO_639_1.length
end
it 'should return nil find_by_code when code does not exist or is invalid' do
- assert ISO_639.find_by_code(nil).nil?, 'nil code'
- assert ISO_639.find_by_code('xxx').nil?, 'xxx alfa-3 not existing code'
- assert ISO_639.find_by_code('xx').nil?, 'xx alfa-2 not existing code'
+ assert ISO_639.find_by_code(nil).nil?, 'nil code'
+ assert ISO_639.find_by_code('xxx').nil?, 'xxx alfa-3 not existing code'
+ assert ISO_639.find_by_code('xx').nil?, 'xx alfa-2 not existing code'
assert ISO_639.find_by_code('xxxx').nil?, 'xxxx lengthy code'
- assert ISO_639.find_by_code('').nil?, 'empty string code'
+ assert ISO_639.find_by_code('').nil?, 'empty string code'
end
it 'should return entry for alpha-2 code' do
assert_equal ['eng', '', 'en', 'English', 'anglais'], ISO_639.find_by_code('en')
assert_equal ['eng', '', 'en', 'English', 'anglais'], ISO_639.find('en')
end
+ it 'should return entry for alpha-3 bibliographic code' do
+ assert_equal %w[ger deu de German allemand], ISO_639.find('ger')
+ end
+
+ it 'should return entry for 7-character alpha-3 terminologic code (qaa-qtz)' do
+ assert_equal ['qaa-qtz', '', '', 'Reserved for local use', "réservée à l'usage local"], ISO_639.find_by_code('qaa-qtz')
+ assert_equal ['qaa-qtz', '', '', 'Reserved for local use', "réservée à l'usage local"], ISO_639.find('qaa-qtz')
+ end
+
it 'should return entry for alpha-3 terminologic code' do
assert_equal %w[ger deu de German allemand], ISO_639.find('deu')
end
it 'should find by english name' do
@@ -44,9 +53,10 @@
english_name
french_name
].each_with_index do |m, i|
it "should respond to and return #{m}" do
@entry = ISO_639.find('en')
+
assert @entry.respond_to?(m)
assert_equal ['eng', 'eng', '', 'en', 'English', 'anglais'][i], @entry.send(m)
end
end