-
Notifications
You must be signed in to change notification settings - Fork 57
/
fallbacks_spec.rb
41 lines (33 loc) · 1.22 KB
/
fallbacks_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
require File.dirname(__FILE__) + '/../spec/helper.rb'
require 'globalize/locale/fallbacks'
require 'globalize/locale/language_tag'
include Globalize::Locale
describe Fallbacks do
before do
@fallbacks = Fallbacks.new
end
it "returns correct fallbacks for en" do
fallbacks = @fallbacks.compute('en')
fallbacks.should == %w[ en ]
end
it "returns correct fallbacks for en-US" do
fallbacks = @fallbacks.compute('en-US')
fallbacks.should == %w[ en-US en ]
end
it "returns correct fallbacks for de, given en as default" do
@fallbacks.add 'de', 'en'
fallbacks = @fallbacks.compute('de')
fallbacks.should == %w[ de en ]
end
it "returns correct fallbacks for de, given en as default; rules specified at initialization" do
fallbacks_obj = Fallbacks.new 'de' => [ 'en', 'he' ]
fallbacks = fallbacks_obj.compute('de')
fallbacks.should == %w[ de en he ]
end
# Add lots of other tests that won't pass and will require changes in code
it "returns correct fallbacks for en-Latn-US" do
fallbacks = @fallbacks.compute('en-Latn-US')
fallbacks.should == %w[ en-Latn-US en-US en-Latn en ]
end
# Test for correct resolution down fallback tree; e.g., 'de-DE' -> 'de' -> 'en'
end