add test for label_text method

This commit is contained in:
Rozhnov Alexandr 2012-09-11 16:45:26 +04:00
parent a8df7c3e15
commit 716b998008
2 changed files with 16 additions and 0 deletions

View File

@ -68,4 +68,14 @@ class LabelTest < ActionView::TestCase
assert_select 'label.integer[for=user_age]', "Age:"
end
end
test 'configuration allow set label text for wrappers' do
swap_wrapper :default, self.custom_wrapper_with_label_text do
with_concat_form_for(@user) do |f|
concat f.input :age
end
assert_select "label.integer[for=user_age]", "**Age**"
end
end
end

View File

@ -84,6 +84,12 @@ module MiscHelpers
end
end
def custom_wrapper_with_label_text
SimpleForm.build :label_text => lambda { |label, required| "**#{label}**" } do |b|
b.use :label_input
end
end
def custom_form_for(object, *args, &block)
simple_form_for(object, *(args << { :builder => CustomFormBuilder }), &block)
end