I18n.locale = :test
assert_equal :test, I18n.locale
assert_equal ',', I18n.translate('number.format.separator')
But this doesn't:
@product = Factory.create(:product, :price => 49.95)
I18n.locale = :test
get :edit, :id => @product.permalink
assert_select "#product_price[value='49,95']"
We're testing the view (@response.body), here, not the controller. But I
can't find where the view is rendered, and why I18n.locale is not used.
Best regards,
Xtian
--
Posted via http://www.ruby-forum.com/.
Locale should be set with each single request, so you should have sth like:
get :edit, :id => @product.permalink, :locale => :en
assert_response :success # I would ensure response 200 status here
assert_select "#product_price[value='49,95']"
--
Regards
KK
> Locale should be set with each single request, so you should have sth
> like:
> get :edit, :id => @product.permalink, :locale => :en
Actually, I did try this, and it doesn't work. I suspect it works if the
:locale parameter is integrated in the route.
Best regards
> So my conclusion is :
>
> Functional test take default_locale variable while is running his
> tests.
It worked for me! I'm not sure it's a general solution, as I use Spree
and I also had to override the Spree config. Here goes:
context "on GET to :edit with :test locale" do
setup do
@product = Factory.create(:product, :price => 49.95)
I18n.default_locale = :test
Spree::Config.set(:default_locale => :test)
get :edit, :id => @product.permalink
end
should "format the price properly" do
assert_select "#product_price[value='49,95']"
end
end
My test.yml file:
test:
number:
format:
separator: ","