Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

add failing specs for magic methods, add hash to map languages to lan…

…guage codes
  • Loading branch information...
commit d08f68d82cf858188290b3fc8905c73e5e564f15 1 parent dc008a8
@jimmycuadra jimmycuadra authored
Showing with 71 additions and 1 deletion.
  1. +1 −0  lib/to_lang.rb
  2. +57 −0 lib/to_lang/codemap.rb
  3. +13 −1 spec/to_lang_spec.rb
View
1  lib/to_lang.rb
@@ -1,3 +1,4 @@
+require File.expand_path("../to_lang/codemap", __FILE__)
require File.expand_path("../to_lang/connector", __FILE__)
module ToLang
View
57 lib/to_lang/codemap.rb
@@ -0,0 +1,57 @@
+module ToLang
+ CODEMAP = {
+ 'afrikaans' => 'af',
+ 'albanian' => 'sq',
+ 'arabic' => 'ar',
+ 'basque' => 'eu',
+ 'belarusian' => 'be',
+ 'bulgarian' => 'bg',
+ 'catalan' => 'ca',
+ 'simplified_chinese' => 'zh-CN',
+ 'traditional_chinese' => 'zh-TW',
+ 'croatian' => 'hr',
+ 'czech' => 'cs',
+ 'danish' => 'da',
+ 'dutch' => 'nl',
+ 'english' => 'en',
+ 'estonian' => 'et',
+ 'filipino' => 'tl',
+ 'finnish' => 'fi',
+ 'french' => 'fr',
+ 'galician' => 'gl',
+ 'german' => 'de',
+ 'greek' => 'el',
+ 'haitian_creole' => 'ht',
+ 'hebrew' => 'iw',
+ 'hindi' => 'hi',
+ 'hungarian' => 'hu',
+ 'icelandic' => 'is',
+ 'indonesian' => 'id',
+ 'irish' => 'ga',
+ 'italian' => 'it',
+ 'japanese' => 'ja',
+ 'latvian' => 'lv',
+ 'lithuanian' => 'lt',
+ 'macedonian' => 'mk',
+ 'malay' => 'ms',
+ 'maltese' => 'mt',
+ 'norwegian' => 'no',
+ 'persian' => 'fa',
+ 'polish' => 'pl',
+ 'portuguese' => 'pt',
+ 'romanian' => 'ro',
+ 'russian' => 'ru',
+ 'serbian' => 'sr',
+ 'slovak' => 'sk',
+ 'slovenian' => 'sl',
+ 'spanish' => 'es',
+ 'swahili' => 'sw',
+ 'swedish' => 'sv',
+ 'thai' => 'th',
+ 'turkish' => 'tr',
+ 'ukrainian' => 'uk',
+ 'vietnamese' => 'vi',
+ 'welsh' => 'cy',
+ 'yiddish' => 'yi',
+ }
+end
View
14 spec/to_lang_spec.rb
@@ -16,7 +16,7 @@
end
end
-describe "An instance of String" do
+describe "A string" do
context "after ToLang has received :start" do
before :all do
ToLang.start('apikey')
@@ -33,5 +33,17 @@
"hello world".translate("es")
end
end
+
+ ToLang::CODEMAP.each do |language, code|
+ it "translates to #{language} when sent :to_#{language}" do
+ ToLang.connector.stub(:request)
+ ToLang.connector.should_receive(:request).with("hello world", code)
+ "hello world".send("to_#{language}")
+ end
+
+ it "will then respond_to? :to_#{language}" do
+ "hello_world".should respond_to "to_#{language}"
+ end
+ end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.