Sha256: e106826abd2d09d6632ae5114cde512f1cc292eba6486cb4c0bb12ad048156cd

Contents?: true

Size: 849 Bytes

Versions: 2

Compression:

Stored size: 849 Bytes

Contents

require 'abstract_unit'

class FormOptionsHelperI18nTests < ActionView::TestCase
  tests ActionView::Helpers::FormOptionsHelper

  def setup
    @prompt_message = 'Select!'
    I18n.backend.send(:init_translations)
    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
    I18n.expects(:translate).with('helpers.select.prompt', { :default => 'Please select' })
    select('post', 'category', [], :prompt => true)
  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>),
      select('post', 'category', [], :prompt => true)
    )
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
activejob-lock-0.0.2 rails/actionview/test/template/form_options_helper_i18n_test.rb
activejob-lock-0.0.1 rails/actionview/test/template/form_options_helper_i18n_test.rb