Class: DynamicFormI18nTest
- Inherits:
-
Test::Unit::TestCase
- Object
- Test::Unit::TestCase
- DynamicFormI18nTest
show all
- Includes:
- ActionView::Context, ActionView::Helpers::DynamicForm
- Defined in:
- lib/dynamic_form/test/dynamic_form_i18n_test.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
#error_message_on, #error_messages_for, #form, #input
Instance Attribute Details
#request ⇒ Object
Returns the value of attribute request.
7
8
9
|
# File 'lib/dynamic_form/test/dynamic_form_i18n_test.rb', line 7
def request
@request
end
|
Instance Method Details
#setup ⇒ Object
9
10
11
12
13
14
15
16
17
18
19
20
21
|
# File 'lib/dynamic_form/test/dynamic_form_i18n_test.rb', line 9
def setup
@object = stub :errors => stub(:count => 1, :full_messages => ['full_messages'])
@object.stubs :to_model => @object
@object.stubs :class => stub(:model_name => stub(:human => ""))
@object_name = 'book_seller'
@object_name_without_underscore = 'book seller'
stubs(:content_tag).returns 'content_tag'
I18n.stubs(:t).with(:'header', :locale => 'en', :scope => [:errors, :template], :count => 1, :model => '').returns "1 error prohibited this from being saved"
I18n.stubs(:t).with(:'body', :locale => 'en', :scope => [:errors, :template]).returns 'There were problems with the following fields:'
end
|
23
24
25
26
|
# File 'lib/dynamic_form/test/dynamic_form_i18n_test.rb', line 23
def
I18n.expects(:t).with(:'header', :locale => 'en', :scope => [:errors, :template], :count => 1, :model => '').never
error_messages_for(:object => @object, :header_message => 'header message', :locale => 'en')
end
|
#test_error_messages_for_given_a_message_option_it_does_not_translate_message ⇒ Object
33
34
35
36
|
# File 'lib/dynamic_form/test/dynamic_form_i18n_test.rb', line 33
def test_error_messages_for_given_a_message_option_it_does_not_translate_message
I18n.expects(:t).with(:'body', :locale => 'en', :scope => [:errors, :template]).never
error_messages_for(:object => @object, :message => 'message', :locale => 'en')
end
|
28
29
30
31
|
# File 'lib/dynamic_form/test/dynamic_form_i18n_test.rb', line 28
def
I18n.expects(:t).with(:'header', :locale => 'en', :scope => [:errors, :template], :count => 1, :model => '').returns 'header message'
error_messages_for(:object => @object, :locale => 'en')
end
|
#test_error_messages_for_given_no_message_option_it_translates_message ⇒ Object
38
39
40
41
|
# File 'lib/dynamic_form/test/dynamic_form_i18n_test.rb', line 38
def test_error_messages_for_given_no_message_option_it_translates_message
I18n.expects(:t).with(:'body', :locale => 'en', :scope => [:errors, :template]).returns 'There were problems with the following fields:'
error_messages_for(:object => @object, :locale => 'en')
end
|