Cleanup tests removing calls to concat

This commit is contained in:
Carlos Antonio da Silva 2010-09-26 19:16:25 -03:00
parent 1048a592eb
commit 146d18e6f8
8 changed files with 38 additions and 39 deletions

View File

@ -4,7 +4,7 @@ class BuilderTest < ActionView::TestCase
# COLLECTION RADIO
test 'collection radio accepts a collection and generate inputs from value method' do
concat(form_for(@user) do |f|
concat f.collection_radio :active, [true, false], :to_s, :to_s
f.collection_radio :active, [true, false], :to_s, :to_s
end)
assert_select 'form input[type=radio][value=true]#user_active_true'
@ -13,7 +13,7 @@ class BuilderTest < ActionView::TestCase
test 'collection radio accepts a collection and generate inputs from label method' do
concat(form_for(@user) do |f|
concat f.collection_radio :active, [true, false], :to_s, :to_s
f.collection_radio :active, [true, false], :to_s, :to_s
end)
assert_select 'form label.collection_radio[for=user_active_true]', 'true'
@ -22,7 +22,7 @@ class BuilderTest < ActionView::TestCase
test 'collection radio accepts checked item' do
concat(form_for(@user) do |f|
concat f.collection_radio :active, [[1, true], [0, false]], :last, :first, :checked => true
f.collection_radio :active, [[1, true], [0, false]], :last, :first, :checked => true
end)
assert_select 'form input[type=radio][value=true][checked=checked]'
@ -32,7 +32,7 @@ class BuilderTest < ActionView::TestCase
test 'collection radio accepts multiple disabled items' do
collection = [[1, true], [0, false], [2, 'other']]
concat(form_for(@user) do |f|
concat f.collection_radio :active, collection, :last, :first, :disabled => [true, false]
f.collection_radio :active, collection, :last, :first, :disabled => [true, false]
end)
assert_select 'form input[type=radio][value=true][disabled=disabled]'
@ -43,7 +43,7 @@ class BuilderTest < ActionView::TestCase
test 'collection radio accepts single disable item' do
collection = [[1, true], [0, false]]
concat(form_for(@user) do |f|
concat f.collection_radio :active, collection, :last, :first, :disabled => true
f.collection_radio :active, collection, :last, :first, :disabled => true
end)
assert_select 'form input[type=radio][value=true][disabled=disabled]'
@ -52,7 +52,7 @@ class BuilderTest < ActionView::TestCase
test 'collection radio accepts html options as input' do
concat(form_for(@user) do |f|
concat f.collection_radio :active, [[1, true], [0, false]], :last, :first, {}, :class => 'radio'
f.collection_radio :active, [[1, true], [0, false]], :last, :first, {}, :class => 'radio'
end)
assert_select 'form input[type=radio][value=true].radio#user_active_true'
@ -63,7 +63,7 @@ class BuilderTest < ActionView::TestCase
test 'collection check box accepts a collection and generate a serie of checkboxes for value method' do
collection = [Tag.new(1, 'Tag 1'), Tag.new(2, 'Tag 2')]
concat(form_for(@user) do |f|
concat f.collection_check_boxes :tag_ids, collection, :id, :name
f.collection_check_boxes :tag_ids, collection, :id, :name
end)
assert_select "form input[type=hidden][name='user[tag_ids][]'][value=]"
@ -74,7 +74,7 @@ class BuilderTest < ActionView::TestCase
test 'collection check box accepts a collection and generate a serie of checkboxes with labels for label method' do
collection = [Tag.new(1, 'Tag 1'), Tag.new(2, 'Tag 2')]
concat(form_for(@user) do |f|
concat f.collection_check_boxes :tag_ids, collection, :id, :name
f.collection_check_boxes :tag_ids, collection, :id, :name
end)
assert_select 'form label.collection_check_boxes[for=user_tag_ids_1]', 'Tag 1'
@ -84,7 +84,7 @@ class BuilderTest < ActionView::TestCase
test 'collection check box accepts selected values as :checked option' do
collection = (1..3).map{|i| [i, "Tag #{i}"] }
concat(form_for(@user) do |f|
concat f.collection_check_boxes :tag_ids, collection, :first, :last, :checked => [1, 3]
f.collection_check_boxes :tag_ids, collection, :first, :last, :checked => [1, 3]
end)
assert_select 'form input[type=checkbox][value=1][checked=checked]'
@ -95,7 +95,7 @@ class BuilderTest < ActionView::TestCase
test 'collection check box accepts a single checked value' do
collection = (1..3).map{|i| [i, "Tag #{i}"] }
concat(form_for(@user) do |f|
concat f.collection_check_boxes :tag_ids, collection, :first, :last, :checked => 3
f.collection_check_boxes :tag_ids, collection, :first, :last, :checked => 3
end)
assert_select 'form input[type=checkbox][value=3][checked=checked]'
@ -106,7 +106,7 @@ class BuilderTest < ActionView::TestCase
test 'collection check box accepts multiple disabled items' do
collection = (1..3).map{|i| [i, "Tag #{i}"] }
concat(form_for(@user) do |f|
concat f.collection_check_boxes :tag_ids, collection, :first, :last, :disabled => [1, 3]
f.collection_check_boxes :tag_ids, collection, :first, :last, :disabled => [1, 3]
end)
assert_select 'form input[type=checkbox][value=1][disabled=disabled]'
@ -117,7 +117,7 @@ class BuilderTest < ActionView::TestCase
test 'collection check box accepts single disable item' do
collection = (1..3).map{|i| [i, "Tag #{i}"] }
concat(form_for(@user) do |f|
concat f.collection_check_boxes :tag_ids, collection, :first, :last, :disabled => 1
f.collection_check_boxes :tag_ids, collection, :first, :last, :disabled => 1
end)
assert_select 'form input[type=checkbox][value=1][disabled=disabled]'
@ -128,7 +128,7 @@ class BuilderTest < ActionView::TestCase
test 'collection check box accepts a proc to disabled items' do
collection = (1..3).map{|i| [i, "Tag #{i}"] }
concat(form_for(@user) do |f|
concat f.collection_check_boxes :tag_ids, collection, :first, :last, :disabled => proc { |i| i.first == 1 }
f.collection_check_boxes :tag_ids, collection, :first, :last, :disabled => proc { |i| i.first == 1 }
end)
assert_select 'form input[type=checkbox][value=1][disabled=disabled]'
@ -139,7 +139,7 @@ class BuilderTest < ActionView::TestCase
test 'collection check box accepts html options' do
collection = [[1, 'Tag 1'], [2, 'Tag 2']]
concat(form_for(@user) do |f|
concat f.collection_check_boxes :tag_ids, collection, :first, :last, {}, :class => 'check'
f.collection_check_boxes :tag_ids, collection, :first, :last, {}, :class => 'check'
end)
assert_select 'form input.check[type=checkbox][value=1]'
@ -149,9 +149,9 @@ class BuilderTest < ActionView::TestCase
test 'collection check box with fields for' do
collection = [Tag.new(1, 'Tag 1'), Tag.new(2, 'Tag 2')]
concat(form_for(@user) do |f|
concat(f.fields_for(:post) do |p|
concat p.collection_check_boxes :tag_ids, collection, :id, :name
end)
f.fields_for(:post) do |p|
p.collection_check_boxes :tag_ids, collection, :id, :name
end
end)
assert_select 'form input#user_post_tag_ids_1[type=checkbox][value=1]'
@ -164,9 +164,9 @@ class BuilderTest < ActionView::TestCase
# SIMPLE FIELDS
test 'simple fields for is available and yields an instance of FormBuilder' do
concat(form_for(@user) do |f|
concat(f.simple_fields_for(:posts) do |posts_form|
f.simple_fields_for(:posts) do |posts_form|
assert posts_form.instance_of?(SimpleForm::FormBuilder)
end)
end
end)
end
end

View File

@ -9,7 +9,7 @@ class ErrorTest < ActionView::TestCase
f.input_type = type
f.options = options
concat(SimpleForm::Inputs::Base.new(f).error.to_s)
SimpleForm::Inputs::Base.new(f).error.to_s
end)
end

View File

@ -9,7 +9,7 @@ class HintTest < ActionView::TestCase
f.input_type = type
f.options = options
concat(SimpleForm::Inputs::Base.new(f).hint.to_s)
SimpleForm::Inputs::Base.new(f).hint.to_s
end)
end

View File

@ -14,7 +14,7 @@ class LabelTest < ActionView::TestCase
f.input_type = type
f.options = options
concat(SimpleForm::Inputs::Base.new(f).label)
SimpleForm::Inputs::Base.new(f).label
end)
end

View File

@ -1,16 +1,15 @@
require 'test_helper'
class WrapperTest < ActionView::TestCase
def with_error_for(object, attribute_name, options={}, &block)
def with_error_for(object, attribute_name, &block)
concat(simple_form_for(object) do |f|
f.options = options
f.input attribute_name
end)
end
def with_form_for(object, *args, &block)
concat(simple_form_for(object) do |f|
concat f.input(*args, &block)
f.input(*args, &block)
end)
end

View File

@ -4,7 +4,7 @@ class ErrorNotificationTest < ActionView::TestCase
def with_error_notification_for(object, options={}, &block)
concat(simple_form_for(object) do |f|
concat(f.error_notification(options))
f.error_notification(options)
end)
end

View File

@ -5,37 +5,37 @@ class FormBuilderTest < ActionView::TestCase
def with_form_for(object, *args, &block)
concat(simple_form_for(object) do |f|
concat f.input(*args, &block)
f.input(*args, &block)
end)
end
def with_button_for(object, *args)
concat(simple_form_for(object) do |f|
concat f.button(*args)
f.button(*args)
end)
end
def with_error_for(object, *args)
concat(simple_form_for(object) do |f|
concat f.error(*args)
f.error(*args)
end)
end
def with_hint_for(object, *args)
concat(simple_form_for(object) do |f|
concat f.hint(*args)
f.hint(*args)
end)
end
def with_label_for(object, *args)
concat(simple_form_for(object) do |f|
concat f.label(*args)
f.label(*args)
end)
end
def with_association_for(object, *args)
concat(simple_form_for(object) do |f|
concat f.association(*args)
f.association(*args)
end)
end
@ -56,7 +56,7 @@ class FormBuilderTest < ActionView::TestCase
test 'builder input should allow a block to configure input' do
with_form_for @user, :name do
concat text_field_tag :foo, :bar, :id => :cool
text_field_tag :foo, :bar, :id => :cool
end
assert_no_select 'input.string'
assert_select 'input#cool'
@ -300,14 +300,14 @@ class FormBuilderTest < ActionView::TestCase
test 'builder allows wrapper tag to be given on demand' do
concat(simple_form_for(@user) do |f|
concat f.input :name, :wrapper_tag => :b
f.input :name, :wrapper_tag => :b
end)
assert_select 'form b.required.string'
end
test 'builder allows wrapper class to be given on demand' do
concat(simple_form_for(@user) do |f|
concat f.input :name, :wrapper_class => :wrapper
f.input :name, :wrapper_class => :wrapper
end)
assert_select 'form div.wrapper.required.string'
end
@ -362,9 +362,9 @@ class FormBuilderTest < ActionView::TestCase
end
test 'builder should generate a hint component tag for the given text' do
with_hint_for @user, 'Hello World!'
assert_select 'span.hint', 'Hello World!'
end
with_hint_for @user, 'Hello World!'
assert_select 'span.hint', 'Hello World!'
end
test 'builder should allow passing options to hint tag' do
with_hint_for @user, :name, :hint => 'Hello World!', :id => 'name_hint'

View File

@ -9,7 +9,7 @@ class InputTest < ActionView::TestCase
def with_input_for(object, attribute_name, type, options={})
concat(simple_form_for(object) do |f|
concat f.input(attribute_name, options.merge(:as => type))
f.input(attribute_name, options.merge(:as => type))
end)
end