Skip to content

Commit

Permalink
Fix typo in ordinals hash
Browse files Browse the repository at this point in the history
  • Loading branch information
sunny committed Dec 16, 2021
1 parent f6cc43e commit 41f6aaa
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 13 deletions.
2 changes: 1 addition & 1 deletion rails/ordinals/fr-CA.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
:"fr-CA": {
"fr-CA": {
number: {
nth: {
ordinals: -> (_key, number:, **_options) {
Expand Down
2 changes: 1 addition & 1 deletion rails/ordinals/fr-CH.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
:"fr-CH": {
"fr-CH": {
number: {
nth: {
ordinals: -> (_key, number:, **_options) {
Expand Down
2 changes: 1 addition & 1 deletion rails/ordinals/fr-FR.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
:"fr-FR": {
"fr-FR": {
number: {
nth: {
ordinals: -> (_key, number:, **_options) {
Expand Down
27 changes: 17 additions & 10 deletions spec/unit/ordinals_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,32 @@
let(:app) { double :app, config: config }
let(:config) { double :config, eager_load_namespaces: [], i18n: I18n }

before do |example|
before do
I18n.available_locales = %w[fr en fr-CA fr-CH fr-FR]

RailsI18n::Railtie.initializers.each { |init| init.run(app) }
I18n.backend.reload!
I18n.locale = example.metadata[:locale]
end

describe 'French', locale: :fr do
describe 'French' do
it 'uses the custom rules' do
ActiveSupport::Inflector.ordinalize(1).should == "1er"
ActiveSupport::Inflector.ordinalize(2).should == "2e"
ActiveSupport::Inflector.ordinalize(3).should == "3e"
%w[fr fr-CA fr-CH fr-FR ].each do |locale|
I18n.with_locale(locale) do
ActiveSupport::Inflector.ordinalize(1).should == "1er"
ActiveSupport::Inflector.ordinalize(2).should == "2e"
ActiveSupport::Inflector.ordinalize(3).should == "3e"
end
end
end
end

describe 'English', locale: :en do
describe 'English' do
it 'uses the default rules' do
ActiveSupport::Inflector.ordinalize(1).should == "1st"
ActiveSupport::Inflector.ordinalize(2).should == "2nd"
ActiveSupport::Inflector.ordinalize(3).should == "3rd"
I18n.with_locale(:en) do
ActiveSupport::Inflector.ordinalize(1).should == "1st"
ActiveSupport::Inflector.ordinalize(2).should == "2nd"
ActiveSupport::Inflector.ordinalize(3).should == "3rd"
end
end
end
end

0 comments on commit 41f6aaa

Please sign in to comment.