test/test_ISO_639.rb in iso-639-0.1.0 vs test/test_ISO_639.rb in iso-639-0.2.0
- old
+ new
@@ -1,5 +1,6 @@
+# encoding: UTF-8
require 'helper'
class TestISO639 < Test::Unit::TestCase
should "have full code list in ISO_639_2" do
@@ -34,8 +35,45 @@
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
+
+ should "return single record array by searching a unique code" do
+ assert_equal(
+ [["spa", "", "es", "Spanish; Castilian", "espagnol; castillan"]],
+ ISO_639.search("es")
+ )
+ end
+
+ should "return single record array by searching a unique term" do
+ assert_equal(
+ [["spa", "", "es", "Spanish; Castilian", "espagnol; castillan"]],
+ ISO_639.search("spanish")
+ )
+ end
+
+ should "return multiple record array by searching a common term" do
+ assert_equal(
+ [
+ ["egy", "", "", "Egyptian (Ancient)", "égyptien"],
+ ["grc", "", "", "Greek, Ancient (to 1453)", "grec ancien (jusqu'à 1453)"]
+ ],
+ ISO_639.search("ancient")
+ )
+ end
+
+ should "return empty array when searching a non-existent term" do
+ assert_equal(
+ [], ISO_639.search("bad term")
+ )
+ end
+
+ should "return single record array by searching a unique multi-word term" do
+ assert_equal(
+ [["ypk", "", "", "Yupik languages", "yupik, langues"]],
+ ISO_639.search("yupik, langues")
+ )
end
end