Permalink
Browse files

Don't upcase language tags. Closes #5

Also restore tests and remove the unnecessary rspec dependencies
(Test::Unit is used, not RSpec)
  • Loading branch information...
1 parent d0a9345 commit 303345685f9f02eb77b42cf27fdc6287dd556f6c @davec davec committed Apr 10, 2011
Showing with 63 additions and 69 deletions.
  1. +2 −2 Gemfile
  2. +34 −46 Gemfile.lock
  3. +20 −10 Rakefile
  4. +1 −1 lib/localized_language_select.rb
  5. +6 −10 test/localized_language_select_test.rb
View
@@ -8,8 +8,8 @@ gem "rails", ">= 2.3.5"
# Add dependencies to develop your gem here.
# Include everything needed to run rake, tests, features, etc.
group :development do
- gem "rspec", ">= 2.3.0"
gem "bundler", "~> 1.0.0"
gem "jeweler", "~> 1.5.2"
- gem "rcov", ">= 0"
+ # gem "rspec", ">= 2.3.0"
+ # gem "rcov", ">= 0"
end
View
@@ -2,35 +2,34 @@ GEM
remote: http://rubygems.org/
specs:
abstract (1.0.0)
- actionmailer (3.0.3)
- actionpack (= 3.0.3)
- mail (~> 2.2.9)
- actionpack (3.0.3)
- activemodel (= 3.0.3)
- activesupport (= 3.0.3)
+ actionmailer (3.0.6)
+ actionpack (= 3.0.6)
+ mail (~> 2.2.15)
+ actionpack (3.0.6)
+ activemodel (= 3.0.6)
+ activesupport (= 3.0.6)
builder (~> 2.1.2)
erubis (~> 2.6.6)
- i18n (~> 0.4)
+ i18n (~> 0.5.0)
rack (~> 1.2.1)
- rack-mount (~> 0.6.13)
- rack-test (~> 0.5.6)
+ rack-mount (~> 0.6.14)
+ rack-test (~> 0.5.7)
tzinfo (~> 0.3.23)
- activemodel (3.0.3)
- activesupport (= 3.0.3)
+ activemodel (3.0.6)
+ activesupport (= 3.0.6)
builder (~> 2.1.2)
- i18n (~> 0.4)
- activerecord (3.0.3)
- activemodel (= 3.0.3)
- activesupport (= 3.0.3)
+ i18n (~> 0.5.0)
+ activerecord (3.0.6)
+ activemodel (= 3.0.6)
+ activesupport (= 3.0.6)
arel (~> 2.0.2)
tzinfo (~> 0.3.23)
- activeresource (3.0.3)
- activemodel (= 3.0.3)
- activesupport (= 3.0.3)
- activesupport (3.0.3)
- arel (2.0.6)
+ activeresource (3.0.6)
+ activemodel (= 3.0.6)
+ activesupport (= 3.0.6)
+ activesupport (3.0.6)
+ arel (2.0.9)
builder (2.1.2)
- diff-lcs (1.1.2)
erubis (2.6.6)
abstract (>= 1.0.0)
git (1.2.5)
@@ -39,45 +38,36 @@ GEM
bundler (~> 1.0.0)
git (>= 1.2.5)
rake
- mail (2.2.14)
+ mail (2.2.15)
activesupport (>= 2.3.6)
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
mime-types (1.16)
polyglot (0.3.1)
- rack (1.2.1)
- rack-mount (0.6.13)
+ rack (1.2.2)
+ rack-mount (0.6.14)
rack (>= 1.0.0)
rack-test (0.5.7)
rack (>= 1.0)
- rails (3.0.3)
- actionmailer (= 3.0.3)
- actionpack (= 3.0.3)
- activerecord (= 3.0.3)
- activeresource (= 3.0.3)
- activesupport (= 3.0.3)
+ rails (3.0.6)
+ actionmailer (= 3.0.6)
+ actionpack (= 3.0.6)
+ activerecord (= 3.0.6)
+ activeresource (= 3.0.6)
+ activesupport (= 3.0.6)
bundler (~> 1.0)
- railties (= 3.0.3)
- railties (3.0.3)
- actionpack (= 3.0.3)
- activesupport (= 3.0.3)
+ railties (= 3.0.6)
+ railties (3.0.6)
+ actionpack (= 3.0.6)
+ activesupport (= 3.0.6)
rake (>= 0.8.7)
thor (~> 0.14.4)
rake (0.8.7)
- rcov (0.9.9)
- rspec (2.4.0)
- rspec-core (~> 2.4.0)
- rspec-expectations (~> 2.4.0)
- rspec-mocks (~> 2.4.0)
- rspec-core (2.4.0)
- rspec-expectations (2.4.0)
- diff-lcs (~> 1.1.2)
- rspec-mocks (2.4.0)
thor (0.14.6)
treetop (1.4.9)
polyglot (>= 0.3.1)
- tzinfo (0.3.23)
+ tzinfo (0.3.26)
PLATFORMS
ruby
@@ -86,5 +76,3 @@ DEPENDENCIES
bundler (~> 1.0.0)
jeweler (~> 1.5.2)
rails (>= 2.3.5)
- rcov
- rspec (>= 2.3.0)
View
@@ -26,18 +26,28 @@ Jeweler::Tasks.new do |gem|
end
Jeweler::RubygemsDotOrgTasks.new
-require 'rspec/core'
-require 'rspec/core/rake_task'
-RSpec::Core::RakeTask.new(:spec) do |spec|
- spec.pattern = FileList['spec/**/*_spec.rb']
-end
+require 'rake/testtask'
-RSpec::Core::RakeTask.new(:rcov) do |spec|
- spec.pattern = 'spec/**/*_spec.rb'
- spec.rcov = true
+Rake::TestTask.new(:test) do |t|
+ t.libs += ['test']
+ t.pattern = 'test/**/*_test.rb'
+ t.verbose = false
end
-task :default => :spec
+task :default => :test
+
+# require 'rspec/core'
+# require 'rspec/core/rake_task'
+# RSpec::Core::RakeTask.new(:spec) do |spec|
+# spec.pattern = FileList['spec/**/*_spec.rb']
+# end
+
+# RSpec::Core::RakeTask.new(:rcov) do |spec|
+# spec.pattern = 'spec/**/*_spec.rb'
+# spec.rcov = true
+# end
+
+# task :default => :spec
require 'rake/rdoctask'
Rake::RDocTask.new do |rdoc|
@@ -47,4 +57,4 @@ Rake::RDocTask.new do |rdoc|
rdoc.title = "localized_language_select #{version}"
rdoc.rdoc_files.include('README*')
rdoc.rdoc_files.include('lib/**/*.rb')
-end
+end
@@ -28,7 +28,7 @@ class << self
def localized_languages_array options = {}
res = []
list = I18n.translate(:languages).each do |key, value|
- res << [value, key.to_s.upcase] if include_language?(key.to_s, options)
+ res << [value, key.to_s] if include_language?(key.to_s, options)
end
res.sort_by { |country| country.first.parameterize }
end
@@ -81,22 +81,18 @@ def test_priority_languages_returns_correctly_and_in_correct_order
end
def test_include_country_rejects_on_except_option
- res = !LocalizedLanguageSelect::include_language?('af', except: ['af'])
- puts "should not include_language? '' except af : #{res}"
+ assert !LocalizedLanguageSelect::include_language?('af', :except => ['af'])
+ assert LocalizedLanguageSelect::include_language?('ad', :except => ['af'])
end
def test_include_country_accept_on_only_option
- res = LocalizedLanguageSelect::include_language?('af', only: ['af'])
- puts "should include_language? 'af' : #{res}"
-
- res = !LocalizedLanguageSelect::include_language?('af', only: ['ad'])
- puts "should not include_language? 'af' : #{res}"
+ assert LocalizedLanguageSelect::include_language?('af', :only => ['af'])
+ assert !LocalizedLanguageSelect::include_language?('af', :only => ['ad'])
end
def test_localized_countries_array_rejects_on_except_option
list = LocalizedLanguageSelect::localized_languages_array(:except => ['af'])
- res = !list.include?(['Afrikaans', 'af'])
- puts "rejected 'af' from array? #{res}"
+ assert !list.include?(['Afrikaans', 'af'])
end
@@ -105,7 +101,7 @@ def test_localized_countries_array_rejects_on_except_option
def setup
['fr', 'en'].each do |locale|
# I18n.load_translations( File.join(File.dirname(__FILE__), '..', 'locale', "#{locale}.rb") ) # <-- Old style! :)
- I18n.load_path += Dir[ File.join(File.dirname(__FILE__), '..', 'locale', "#{locale}.rb") ]
+ I18n.load_path += Dir[ File.join(File.dirname(__FILE__), '..', 'locale', "#{locale}.{rb,yml}") ]
end
I18n.locale = 'en'
end

0 comments on commit 3033456

Please sign in to comment.