File: form_options_helper_i18n_test.rb

package info (click to toggle)
rails 2.3.5-1.2%2Bsqueeze8
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 18,248 kB
  • ctags: 20,944
  • sloc: ruby: 122,413; makefile: 72; sql: 43; sh: 1
file content (27 lines) | stat: -rw-r--r-- 848 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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, :support => { :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('support.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