1 require File.expand_path("spec_helper", File.dirname(__FILE__))
3 NUM_2_LETTER_LANGUAGES = 185
7 require "i18n_data/live_data_provider"
8 require "i18n_data/file_data_provider"
9 [I18nData::LiveDataProvider,I18nData::FileDataProvider].each do |provider|
10 describe "using #{provider}" do
12 I18nData.data_provider = provider
14 describe :languages do
15 it "raises NoTranslationAvailable for unavailable languages" do
16 lambda{I18nData.languages('XX')}.should raise_error(I18nData::NoTranslationAvailable)
19 it "does not contain blanks" do
20 I18nData.languages.detect {|k,v| k.blank? or v.blank?}.should == nil
22 it "has english as default" do
23 I18nData.languages['DE'].should == 'German'
25 it "contains all languages" do
26 I18nData.languages.size.should == NUM_2_LETTER_LANGUAGES
29 describe :translated do
31 I18nData.languages('DE')['DE'].should == 'Deutsch'
33 it "contains all languages" do
34 I18nData.languages('DE').size.should == NUM_2_LETTER_LANGUAGES
36 it "has english names for not-translateable languages" do
37 I18nData.languages('IS')['HA'].should == I18nData.languages['HA']
39 it "does not contain blanks" do
40 I18nData.languages('GL').detect {|k,v| k.blank? or v.blank?}.should == nil
42 it "is written in unicode" do
43 I18nData.languages('DE')['DA'].should == 'Dänisch'
47 describe :countries do
49 it "has english as default" do
50 I18nData.countries['DE'].should == 'Germany'
52 it "does not contain blanks" do
53 I18nData.countries.detect {|k,v| k.blank? or v.blank?}.should == nil
55 it "contains all countries" do
56 I18nData.countries.size.should == NUM_COUNTRIES
59 describe :translated do
61 I18nData.countries('DE')['DE'].should == 'Deutschland'
63 it "contains all countries" do
64 I18nData.countries('DE').size.should == NUM_COUNTRIES
66 it "has english names for not-translateable countries" do
67 I18nData.countries('IS')['PK'].should == I18nData.countries['PK']
69 it "does not contain blanks" do
70 I18nData.countries('GL').detect {|k,v| k.blank? or v.blank?}.should == nil
72 it "is written in unicode" do
73 I18nData.countries('DE')['DK'].should == 'Dänemark'