1 require File.join( File.dirname(__FILE__), 'test_helper' )
2 require 'globalize/load_path'
4 class LoadPathTest < ActiveSupport::TestCase
6 @plugin_dir = "#{File.dirname(__FILE__)}/.."
7 @locale_dir = "#{File.dirname(__FILE__)}/data/locale"
8 @load_path = Globalize::LoadPath.new
11 test "returns glob patterns for all locales and ruby + yaml files by default" do
12 patterns = %w(locales/all.rb
18 assert_equal patterns, @load_path.send(:patterns, 'locales')
21 test "returns the glob patterns for registered locales and extensions" do
22 @load_path.locales = [:en, :de]
23 @load_path.extensions = [:sql]
24 patterns = %w(locales/all.sql
29 assert_equal patterns, @load_path.send(:patterns, 'locales')
32 test "expands paths using yml as a default file extension" do
33 @load_path << @locale_dir
34 expected = %w(all.yml de-DE.yml en-US.yml en-US/module.yml fi-FI/module.yml root.yml)
35 assert_equal expected, @load_path.map{|path| path.sub("#{@locale_dir}\/", '')}
38 test "appends new paths to the collection so earlier collected paths preceed later collected ones" do
39 @load_path.locales = [:root]
40 @load_path << "#{@plugin_dir}/lib/locale"
41 @load_path << @locale_dir
43 expected = %W(#{@plugin_dir}/lib/locale/root.yml
44 #{@locale_dir}/all.yml
45 #{@locale_dir}/root.yml)
46 assert_equal expected, @load_path