Hi all,
I have two locales FR and EN.
So, to test EN locale, I make volontary mistakes in my
alert_collaborator EN YML File translation to test if the EN locale is
set.
First of all, in my /config/environnement.rb I have
Rails::Initializer.run do |config|
[…]
config.i18n.load_path += Dir[Rails.root.join(‘config’, ‘locales’,
‘**’, ‘*.{rb,yml}’)]
config.i18n.default_locale = :fr
end
If i’m starting my prospects_controller_test.rb with no mistakes in my
FR YML File, there are no problem.
Started
…
Finished in 6.043841 seconds.
33 tests, 50 assertions, 0 failures, 0 errors
So, if a specify “I18n.locale = :en” in my setup functional test, like
this.
setup do
UserSession.create(Factory(:user))
Factory(:agency)
Factory(:feedback)
@alert_collaborator = Factory.stub(:alert_collaborator)
@alert_collaborator.id = 1001
AlertCollaborator.stubs(:find).returns(@alert_collaborator)
AlertCollaborator.stubs(:find).with(:all,
anything).returns([@alert_collaborator])
I18n.locale = :en
end
There are no problem even if EN YML File translation contain an error.
It’s strange.
But, if I remplace “I18n.locale = :en” by “I18n.default_locale = :en”,
like this.
setup do
UserSession.create(Factory(:user))
Factory(:agency)
Factory(:feedback)
@alert_collaborator = Factory.stub(:alert_collaborator)
@alert_collaborator.id = 1001
AlertCollaborator.stubs(:find).returns(@alert_collaborator)
AlertCollaborator.stubs(:find).with(:all,
anything).returns([@alert_collaborator])
I18n.default_locale = :en
end
Mistakes appears.
Loaded suite functional/hr/alert_collaborators_controller_test
Started
…EEEE…EEE…
Finished in 5.872202 seconds.
So my conclusion is :
Functional test take default_locale variable while is running his
tests.
If we specify a locale changement in functional test with #locale
method from I18n module, it mustn’t be take care of it.