1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/actionview/test/template/form_options_helper_i18n_test.rb

31 lines
884 B
Ruby
Raw Normal View History

# frozen_string_literal: true
require "abstract_unit"
class FormOptionsHelperI18nTests < ActionView::TestCase
tests ActionView::Helpers::FormOptionsHelper
def setup
@prompt_message = "Select!"
I18n.backend.send(:init_translations)
2016-08-06 13:36:34 -04:00
I18n.backend.store_translations :en, helpers: { select: { prompt: @prompt_message } }
end
def teardown
I18n.backend = I18n::Backend::Simple.new
end
def test_select_with_prompt_true_translates_prompt_message
2016-08-06 13:36:34 -04:00
assert_called_with(I18n, :translate, ["helpers.select.prompt", { default: "Please select" }]) do
select("post", "category", [], prompt: true)
2015-08-22 00:03:53 -04:00
end
end
def test_select_with_translated_prompt
assert_dom_equal(
%Q(<select id="post_category" name="post[category]"><option value="">#{@prompt_message}</option>\n</select>),
2016-08-06 13:36:34 -04:00
select("post", "category", [], prompt: true)
)
end
end