From 12e6d89b77a45e2971a114afe87d1e3c85148773 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Mon, 8 Sep 2014 17:19:40 -0300 Subject: [PATCH] Remove all warnings of invalid CSS selector --- test/action_view_extensions/builder_test.rb | 62 ++++++++-------- .../form_helper_test.rb | 2 +- test/components/label_test.rb | 2 +- test/form_builder/association_test.rb | 74 +++++++++---------- test/form_builder/button_test.rb | 10 +-- test/form_builder/input_field_test.rb | 6 +- test/inputs/collection_select_input_test.rb | 34 ++++----- test/inputs/datetime_input_test.rb | 2 +- .../grouped_collection_select_input_test.rb | 16 ++-- test/inputs/numeric_input_test.rb | 38 +++++----- test/inputs/priority_input_test.rb | 12 +-- test/inputs/string_input_test.rb | 20 ++--- test/inputs/text_input_test.rb | 6 +- 13 files changed, 142 insertions(+), 142 deletions(-) diff --git a/test/action_view_extensions/builder_test.rb b/test/action_view_extensions/builder_test.rb index 47f6b63b..d2e3902d 100644 --- a/test/action_view_extensions/builder_test.rb +++ b/test/action_view_extensions/builder_test.rb @@ -263,15 +263,15 @@ class BuilderTest < ActionView::TestCase collection = [Tag.new(1, 'Tag 1'), Tag.new(2, 'Tag 2')] with_collection_check_boxes @user, :tag_ids, collection, :id, :name - assert_select 'form input#user_tag_ids_1[type=checkbox][value=1]' - assert_select 'form input#user_tag_ids_2[type=checkbox][value=2]' + assert_select 'form input#user_tag_ids_1[type=checkbox][value="1"]' + assert_select 'form input#user_tag_ids_2[type=checkbox][value="2"]' end test "collection check box generates only one hidden field for the entire collection, to ensure something will be sent back to the server when posting an empty collection" do collection = [Tag.new(1, 'Tag 1'), Tag.new(2, 'Tag 2')] with_collection_check_boxes @user, :tag_ids, collection, :id, :name - assert_select "form input[type=hidden][name='user[tag_ids][]'][value=]", count: 1 + assert_select 'form input[type=hidden][name="user[tag_ids][]"][value=""]', count: 1 end test "collection check box accepts a collection and generate a serie of checkboxes with labels for label method" do @@ -301,36 +301,36 @@ class BuilderTest < ActionView::TestCase with_collection_check_boxes user, :tag_ids, collection, :first, :last - assert_select 'form input[type=checkbox][value=1][checked=checked]' - assert_select 'form input[type=checkbox][value=3][checked=checked]' - assert_no_select 'form input[type=checkbox][value=2][checked=checked]' + assert_select 'form input[type=checkbox][value="1"][checked=checked]' + assert_select 'form input[type=checkbox][value="3"][checked=checked]' + assert_no_select 'form input[type=checkbox][value="2"][checked=checked]' end test "collection check box accepts selected values as :checked option" do collection = (1..3).map { |i| [i, "Tag #{i}"] } with_collection_check_boxes @user, :tag_ids, collection, :first, :last, checked: [1, 3] - assert_select 'form input[type=checkbox][value=1][checked=checked]' - assert_select 'form input[type=checkbox][value=3][checked=checked]' - assert_no_select 'form input[type=checkbox][value=2][checked=checked]' + assert_select 'form input[type=checkbox][value="1"][checked=checked]' + assert_select 'form input[type=checkbox][value="3"][checked=checked]' + assert_no_select 'form input[type=checkbox][value="2"][checked=checked]' end test "collection check boxes accepts selected string values as :checked option" do collection = (1..3).map { |i| [i, "Category #{i}"] } with_collection_check_boxes :user, :category_ids, collection, :first, :last, checked: ['1', '3'] - assert_select 'input[type=checkbox][value=1][checked=checked]' - assert_select 'input[type=checkbox][value=3][checked=checked]' - assert_no_select 'input[type=checkbox][value=2][checked=checked]' + assert_select 'input[type=checkbox][value="1"][checked=checked]' + assert_select 'input[type=checkbox][value="3"][checked=checked]' + assert_no_select 'input[type=checkbox][value="2"][checked=checked]' end test "collection check box accepts a single checked value" do collection = (1..3).map { |i| [i, "Tag #{i}"] } with_collection_check_boxes @user, :tag_ids, collection, :first, :last, checked: 3 - assert_select 'form input[type=checkbox][value=3][checked=checked]' - assert_no_select 'form input[type=checkbox][value=1][checked=checked]' - assert_no_select 'form input[type=checkbox][value=2][checked=checked]' + assert_select 'form input[type=checkbox][value="3"][checked=checked]' + assert_no_select 'form input[type=checkbox][value="1"][checked=checked]' + assert_no_select 'form input[type=checkbox][value="2"][checked=checked]' end test "collection check box accepts selected values as :checked option and override the model values" do @@ -338,44 +338,44 @@ class BuilderTest < ActionView::TestCase @user.tag_ids = [2] with_collection_check_boxes @user, :tag_ids, collection, :first, :last, checked: [1, 3] - assert_select 'form input[type=checkbox][value=1][checked=checked]' - assert_select 'form input[type=checkbox][value=3][checked=checked]' - assert_no_select 'form input[type=checkbox][value=2][checked=checked]' + assert_select 'form input[type=checkbox][value="1"][checked=checked]' + assert_select 'form input[type=checkbox][value="3"][checked=checked]' + assert_no_select 'form input[type=checkbox][value="2"][checked=checked]' end test "collection check box accepts multiple disabled items" do collection = (1..3).map { |i| [i, "Tag #{i}"] } with_collection_check_boxes @user, :tag_ids, collection, :first, :last, disabled: [1, 3] - assert_select 'form input[type=checkbox][value=1][disabled=disabled]' - assert_select 'form input[type=checkbox][value=3][disabled=disabled]' - assert_no_select 'form input[type=checkbox][value=2][disabled=disabled]' + assert_select 'form input[type=checkbox][value="1"][disabled=disabled]' + assert_select 'form input[type=checkbox][value="3"][disabled=disabled]' + assert_no_select 'form input[type=checkbox][value="2"][disabled=disabled]' end test "collection check box accepts single disable item" do collection = (1..3).map { |i| [i, "Tag #{i}"] } with_collection_check_boxes @user, :tag_ids, collection, :first, :last, disabled: 1 - assert_select 'form input[type=checkbox][value=1][disabled=disabled]' - assert_no_select 'form input[type=checkbox][value=3][disabled=disabled]' - assert_no_select 'form input[type=checkbox][value=2][disabled=disabled]' + assert_select 'form input[type=checkbox][value="1"][disabled=disabled]' + assert_no_select 'form input[type=checkbox][value="3"][disabled=disabled]' + assert_no_select 'form input[type=checkbox][value="2"][disabled=disabled]' end test "collection check box accepts a proc to disabled items" do collection = (1..3).map { |i| [i, "Tag #{i}"] } with_collection_check_boxes @user, :tag_ids, collection, :first, :last, disabled: proc { |i| i.first == 1 } - assert_select 'form input[type=checkbox][value=1][disabled=disabled]' - assert_no_select 'form input[type=checkbox][value=3][disabled=disabled]' - assert_no_select 'form input[type=checkbox][value=2][disabled=disabled]' + assert_select 'form input[type=checkbox][value="1"][disabled=disabled]' + assert_no_select 'form input[type=checkbox][value="3"][disabled=disabled]' + assert_no_select 'form input[type=checkbox][value="2"][disabled=disabled]' end test "collection check box accepts html options" do collection = [[1, 'Tag 1'], [2, 'Tag 2']] with_collection_check_boxes @user, :tag_ids, collection, :first, :last, {}, class: 'check' - assert_select 'form input.check[type=checkbox][value=1]' - assert_select 'form input.check[type=checkbox][value=2]' + assert_select 'form input.check[type=checkbox][value="1"]' + assert_select 'form input.check[type=checkbox][value="2"]' end test "collection check box with fields for" do @@ -386,8 +386,8 @@ class BuilderTest < ActionView::TestCase end end - assert_select 'form input#user_post_tag_ids_1[type=checkbox][value=1]' - assert_select 'form input#user_post_tag_ids_2[type=checkbox][value=2]' + assert_select 'form input#user_post_tag_ids_1[type=checkbox][value="1"]' + assert_select 'form input#user_post_tag_ids_2[type=checkbox][value="2"]' assert_select 'form label.collection_check_boxes[for=user_post_tag_ids_1]', 'Tag 1' assert_select 'form label.collection_check_boxes[for=user_post_tag_ids_2]', 'Tag 2' diff --git a/test/action_view_extensions/form_helper_test.rb b/test/action_view_extensions/form_helper_test.rb index 1839eae1..25b444a2 100644 --- a/test/action_view_extensions/form_helper_test.rb +++ b/test/action_view_extensions/form_helper_test.rb @@ -87,7 +87,7 @@ class FormHelperTest < ActionView::TestCase test 'passes options to SimpleForm' do with_concat_form_for(:user, url: '/account', html: { id: 'my_form' }) assert_select 'form#my_form' - assert_select 'form[action=/account]' + assert_select 'form[action="/account"]' end test 'form_for yields an instance of FormBuilder' do diff --git a/test/components/label_test.rb b/test/components/label_test.rb index 7807aec6..f6280577 100644 --- a/test/components/label_test.rb +++ b/test/components/label_test.rb @@ -244,7 +244,7 @@ class IsolatedLabelTest < ActionView::TestCase test 'label uses i18n to find required text' do store_translations(:en, simple_form: { required: { text: 'campo requerido' } }) do with_label_for @user, :name, :string - assert_select 'form label abbr[title=campo requerido]', '*' + assert_select 'form label abbr[title="campo requerido"]', '*' end end diff --git a/test/form_builder/association_test.rb b/test/form_builder/association_test.rb index 2e4d77b1..d8a9b6f8 100644 --- a/test/form_builder/association_test.rb +++ b/test/form_builder/association_test.rb @@ -46,9 +46,9 @@ class AssociationTest < ActionView::TestCase with_association_for @user, :tags assert_select 'form select.select#user_tag_ids' - assert_select 'form select option[value=1]', 'Tag 1' - assert_select 'form select option[value=2]', 'Tag 2' - assert_select 'form select option[value=3]', 'Tag 3' + assert_select 'form select option[value="1"]', 'Tag 1' + assert_select 'form select option[value="2"]', 'Tag 2' + assert_select 'form select option[value="3"]', 'Tag 3' value.verify end @@ -59,9 +59,9 @@ class AssociationTest < ActionView::TestCase with_association_for @user, :tags, preload: false assert_select 'form select.select#user_tag_ids' - assert_select 'form select option[value=1]', 'Tag 1' - assert_select 'form select option[value=2]', 'Tag 2' - assert_select 'form select option[value=3]', 'Tag 3' + assert_select 'form select option[value="1"]', 'Tag 1' + assert_select 'form select option[value="2"]', 'Tag 2' + assert_select 'form select option[value="3"]', 'Tag 3' assert_raises MockExpectationError do value.verify @@ -74,9 +74,9 @@ class AssociationTest < ActionView::TestCase with_association_for @user, :company assert_select 'form select.select#user_company_id' - assert_select 'form select option[value=1]', 'Company 1' - assert_select 'form select option[value=2]', 'Company 2' - assert_select 'form select option[value=3]', 'Company 3' + assert_select 'form select option[value="1"]', 'Company 1' + assert_select 'form select option[value="2"]', 'Company 2' + assert_select 'form select option[value="3"]', 'Company 3' assert_raises MockExpectationError do value.verify @@ -87,15 +87,15 @@ class AssociationTest < ActionView::TestCase test 'builder creates a select for belongs_to associations' do with_association_for @user, :company assert_select 'form select.select#user_company_id' - assert_select 'form select option[value=1]', 'Company 1' - assert_select 'form select option[value=2]', 'Company 2' - assert_select 'form select option[value=3]', 'Company 3' + assert_select 'form select option[value="1"]', 'Company 1' + assert_select 'form select option[value="2"]', 'Company 2' + assert_select 'form select option[value="3"]', 'Company 3' end test 'builder creates blank select if collection is nil' do with_association_for @user, :company, collection: nil assert_select 'form select.select#user_company_id' - assert_no_select 'form select option[value=1]', 'Company 1' + assert_no_select 'form select option[value="1"]', 'Company 1' end test 'builder allows collection radio for belongs_to associations' do @@ -108,17 +108,17 @@ class AssociationTest < ActionView::TestCase test 'builder allows collection to have a proc as a condition' do with_association_for @user, :extra_special_company assert_select 'form select.select#user_extra_special_company_id' - assert_select 'form select option[value=1]' - assert_no_select 'form select option[value=2]' - assert_no_select 'form select option[value=3]' + assert_select 'form select option[value="1"]' + assert_no_select 'form select option[value="2"]' + assert_no_select 'form select option[value="3"]' end test 'builder allows collection to have a scope' do with_association_for @user, :special_pictures assert_select 'form select.select#user_special_picture_ids' - assert_select 'form select option[value=3]', '3' - assert_no_select 'form select option[value=1]' - assert_no_select 'form select option[value=2]' + assert_select 'form select option[value="3"]', '3' + assert_no_select 'form select option[value="1"]' + assert_no_select 'form select option[value="2"]' end test 'builder marks the record which already belongs to the user' do @@ -133,17 +133,17 @@ class AssociationTest < ActionView::TestCase test 'builder uses reflection conditions to find collection' do with_association_for @user, :special_company assert_select 'form select.select#user_special_company_id' - assert_select 'form select option[value=1]' - assert_no_select 'form select option[value=2]' - assert_no_select 'form select option[value=3]' + assert_select 'form select option[value="1"]' + assert_no_select 'form select option[value="2"]' + assert_no_select 'form select option[value="3"]' end test 'builder allows overriding collection to association input' do with_association_for @user, :company, include_blank: false, collection: [Company.new(999, 'Teste')] assert_select 'form select.select#user_company_id' - assert_no_select 'form select option[value=1]' - assert_select 'form select option[value=999]', 'Teste' + assert_no_select 'form select option[value="1"]' + assert_select 'form select option[value="999"]', 'Teste' assert_select 'form select option', count: 1 end @@ -158,31 +158,31 @@ class AssociationTest < ActionView::TestCase with_association_for @user, :pictures assert_select 'form select.select#user_picture_ids' assert_select 'form select[multiple=multiple]' - assert_select 'form select option[value=1]', 'Picture 1' - assert_select 'form select option[value=2]', 'Picture 2' - assert_select 'form select option[value=3]', 'Picture 3' + assert_select 'form select option[value="1"]', 'Picture 1' + assert_select 'form select option[value="2"]', 'Picture 2' + assert_select 'form select option[value="3"]', 'Picture 3' end test 'builder creates a select with multiple options for collection associations' do with_association_for @user, :tags assert_select 'form select.select#user_tag_ids' assert_select 'form select[multiple=multiple]' - assert_select 'form select option[value=1]', 'Tag 1' - assert_select 'form select option[value=2]', 'Tag 2' - assert_select 'form select option[value=3]', 'Tag 3' + assert_select 'form select option[value="1"]', 'Tag 1' + assert_select 'form select option[value="2"]', 'Tag 2' + assert_select 'form select option[value="3"]', 'Tag 3' end test 'builder allows size to be overwritten for collection associations' do with_association_for @user, :tags, input_html: { size: 10 } - assert_select 'form select[multiple=multiple][size=10]' + assert_select 'form select[multiple=multiple][size="10"]' end test 'builder marks all selected records which already belongs to user' do @user.tag_ids = [1, 2] with_association_for @user, :tags - assert_select 'form select option[value=1][selected=selected]' - assert_select 'form select option[value=2][selected=selected]' - assert_no_select 'form select option[value=3][selected=selected]' + assert_select 'form select option[value="1"][selected=selected]' + assert_select 'form select option[value="2"][selected=selected]' + assert_no_select 'form select option[value="3"][selected=selected]' end test 'builder allows a collection of check boxes for collection associations' do @@ -196,9 +196,9 @@ class AssociationTest < ActionView::TestCase test 'builder marks all selected records for collection boxes' do @user.tag_ids = [1, 2] with_association_for @user, :tags, as: :check_boxes - assert_select 'form input[type=checkbox][value=1][checked=checked]' - assert_select 'form input[type=checkbox][value=2][checked=checked]' - assert_no_select 'form input[type=checkbox][value=3][checked=checked]' + assert_select 'form input[type=checkbox][value="1"][checked=checked]' + assert_select 'form input[type=checkbox][value="2"][checked=checked]' + assert_no_select 'form input[type=checkbox][value="3"][checked=checked]' end test 'builder with collection support giving collection and item wrapper tags' do diff --git a/test/form_builder/button_test.rb b/test/form_builder/button_test.rb index dc317d36..cd8899bb 100644 --- a/test/form_builder/button_test.rb +++ b/test/form_builder/button_test.rb @@ -10,31 +10,31 @@ class ButtonTest < ActionView::TestCase test 'builder creates buttons' do with_button_for :post, :submit - assert_select 'form input.button[type=submit][value=Save Post]' + assert_select 'form input.button[type=submit][value="Save Post"]' end test 'builder creates buttons with options' do with_button_for :post, :submit, class: 'my_button' - assert_select 'form input.button.my_button[type=submit][value=Save Post]' + assert_select 'form input.button.my_button[type=submit][value="Save Post"]' end test 'builder does not modify the options hash' do options = { class: 'my_button' } with_button_for :post, :submit, options - assert_select 'form input.button.my_button[type=submit][value=Save Post]' + assert_select 'form input.button.my_button[type=submit][value="Save Post"]' assert_equal({ class: 'my_button' }, options) end test 'builder creates buttons for records' do @user.new_record! with_button_for @user, :submit - assert_select 'form input.button[type=submit][value=Create User]' + assert_select 'form input.button[type=submit][value="Create User"]' end test "builder uses the default class from the configuration" do swap SimpleForm, button_class: 'btn' do with_button_for :post, :submit - assert_select 'form input.btn[type=submit][value=Save Post]' + assert_select 'form input.btn[type=submit][value="Save Post"]' end end diff --git a/test/form_builder/input_field_test.rb b/test/form_builder/input_field_test.rb index af8f0266..aefc88e8 100644 --- a/test/form_builder/input_field_test.rb +++ b/test/form_builder/input_field_test.rb @@ -76,7 +76,7 @@ class InputFieldTest < ActionView::TestCase f.input_field :name end - assert_select 'input.string[placeholder=Name goes here]' + assert_select 'input.string[placeholder="Name goes here"]' end end @@ -85,7 +85,7 @@ class InputFieldTest < ActionView::TestCase f.input_field :age, as: :integer end - assert_select 'input[min=18]' + assert_select 'input[min="18"]' end test 'builder input_field does not use pattern component by default' do @@ -125,7 +125,7 @@ class InputFieldTest < ActionView::TestCase f.input_field :name, as: :string end - assert_select 'input.string[maxlength=25]' + assert_select 'input.string[maxlength="25"]' end test 'builder collection input_field generates input tag with a clean HTML' do diff --git a/test/inputs/collection_select_input_test.rb b/test/inputs/collection_select_input_test.rb index 85446d5a..b3bb3bbb 100644 --- a/test/inputs/collection_select_input_test.rb +++ b/test/inputs/collection_select_input_test.rb @@ -99,7 +99,7 @@ class CollectionSelectInputTest < ActionView::TestCase test 'input automatically sets include blank' do with_input_for @user, :age, :select, collection: 18..30 - assert_select 'select option[value=]', '' + assert_select 'select option[value=""]', '' end test 'input translates include blank when set to :translate' do @@ -107,7 +107,7 @@ class CollectionSelectInputTest < ActionView::TestCase age: 'Rather not say' } } }) do with_input_for @user, :age, :select, collection: 18..30, include_blank: :translate - assert_select 'select option[value=]', 'Rather not say' + assert_select 'select option[value=""]', 'Rather not say' end end @@ -116,7 +116,7 @@ class CollectionSelectInputTest < ActionView::TestCase age: 'Rather not say', } } }) do with_input_for @user, :age, :select, collection: 18..30, include_blank: :translate - assert_select 'select option[value=]', 'Rather not say' + assert_select 'select option[value=""]', 'Rather not say' end end @@ -125,7 +125,7 @@ class CollectionSelectInputTest < ActionView::TestCase age: 'Rather not say' } } }) do with_input_for @user, :age, :select, collection: 18..30, include_blank: 'Young at heart' - assert_select 'select option[value=]', 'Young at heart' + assert_select 'select option[value=""]', 'Young at heart' end end @@ -134,7 +134,7 @@ class CollectionSelectInputTest < ActionView::TestCase age: 'Rather not say' } } }) do with_input_for @user, :age, :select, collection: 18..30 - assert_select 'select option[value=]', '' + assert_select 'select option[value=""]', '' end end @@ -143,7 +143,7 @@ class CollectionSelectInputTest < ActionView::TestCase age: 'Rather not say' } } }) do with_input_for @user, :age, :select, collection: 18..30, include_blank: true - assert_select 'select option[value=]', '' + assert_select 'select option[value=""]', '' end end @@ -152,23 +152,23 @@ class CollectionSelectInputTest < ActionView::TestCase age: 'Rather not say' } } }) do with_input_for @user, :age, :select, collection: 18..30, include_blank: false - assert_no_select 'select option[value=]' + assert_no_select 'select option[value=""]' end end test 'input does not set include blank if otherwise is told' do with_input_for @user, :age, :select, collection: 18..30, include_blank: false - assert_no_select 'select option[value=]' + assert_no_select 'select option[value=""]' end test 'input does not set include blank if prompt is given' do with_input_for @user, :age, :select, collection: 18..30, prompt: "Please select foo" - assert_no_select 'select option[value=]', '' + assert_no_select 'select option[value=""]', '' end test 'input does not set include blank if multiple is given' do with_input_for @user, :age, :select, collection: 18..30, input_html: { multiple: true } - assert_no_select 'select option[value=]', '' + assert_no_select 'select option[value=""]', '' end test 'input translates prompt when set to :translate' do @@ -176,7 +176,7 @@ class CollectionSelectInputTest < ActionView::TestCase age: 'Select age:' } } }) do with_input_for @user, :age, :select, collection: 18..30, prompt: :translate - assert_select 'select option[value=]', 'Select age:' + assert_select 'select option[value=""]', 'Select age:' end end @@ -185,7 +185,7 @@ class CollectionSelectInputTest < ActionView::TestCase age: 'Select age:', } } }) do with_input_for @user, :age, :select, collection: 18..30, prompt: :translate - assert_select 'select option[value=]', 'Select age:' + assert_select 'select option[value=""]', 'Select age:' end end @@ -194,7 +194,7 @@ class CollectionSelectInputTest < ActionView::TestCase age: 'Select age:' } } }) do with_input_for @user, :age, :select, collection: 18..30, prompt: 'Do it:' - assert_select 'select option[value=]', 'Do it:' + assert_select 'select option[value=""]', 'Do it:' end end @@ -203,7 +203,7 @@ class CollectionSelectInputTest < ActionView::TestCase age: 'Select age:' } } }) do with_input_for @user, :age, :select, collection: 18..30, prompt: false - assert_no_select 'select option[value=]' + assert_no_select 'select option[value=""]' end end @@ -212,15 +212,15 @@ class CollectionSelectInputTest < ActionView::TestCase prompt: 'Select value:' } }) do with_input_for @user, :age, :select, collection: 18..30, prompt: :translate - assert_select 'select option[value=]', "Select value:" + assert_select 'select option[value=""]', "Select value:" end end test 'input detects label and value on collections' do users = [User.build(id: 1, name: "Jose"), User.build(id: 2, name: "Carlos")] with_input_for @user, :description, :select, collection: users - assert_select 'select option[value=1]', 'Jose' - assert_select 'select option[value=2]', 'Carlos' + assert_select 'select option[value="1"]', 'Jose' + assert_select 'select option[value="2"]', 'Carlos' end test 'input disables the anothers components when the option is a object' do diff --git a/test/inputs/datetime_input_test.rb b/test/inputs/datetime_input_test.rb index 0d84a46f..dd0efe4b 100644 --- a/test/inputs/datetime_input_test.rb +++ b/test/inputs/datetime_input_test.rb @@ -102,7 +102,7 @@ class DateTimeInputWithoutHtml5Test < ActionView::TestCase test 'input is able to pass :default to date select' do with_input_for @user, :born_at, :date, default: Date.today, html5: false - assert_select "select.date option[value=#{Date.today.year}][selected=selected]" + assert_select "select.date option[value='#{Date.today.year}'][selected=selected]" end test 'input generates a date input for date attributes if HTML5 compatibility is explicitly enabled' do diff --git a/test/inputs/grouped_collection_select_input_test.rb b/test/inputs/grouped_collection_select_input_test.rb index b72f1647..269483a9 100644 --- a/test/inputs/grouped_collection_select_input_test.rb +++ b/test/inputs/grouped_collection_select_input_test.rb @@ -109,8 +109,8 @@ class GroupedCollectionSelectInputTest < ActionView::TestCase assert_select 'select.grouped_select#user_tag_ids' do assert_select 'optgroup[label=Second]' do - assert_select 'option[value=7]', 'Bond' - assert_select 'option[value=47]', 'Hitman' + assert_select 'option[value="7"]', 'Bond' + assert_select 'option[value="47"]', 'Hitman' end end end @@ -155,14 +155,14 @@ class GroupedCollectionSelectInputTest < ActionView::TestCase collection: tag_groups, group_method: :tags assert_select 'select.grouped_select#user_tag_ids' do - assert_select 'optgroup[label=Group of Tags]' do - assert_select 'option[value=1]', 'Tag 1' - assert_select 'option[value=2]', 'Tag 2' + assert_select 'optgroup[label="Group of Tags"]' do + assert_select 'option[value="1"]', 'Tag 1' + assert_select 'option[value="2"]', 'Tag 2' end - assert_select 'optgroup[label=Other group]' do - assert_select 'option[value=3]', 'Tag 3' - assert_select 'option[value=4]', 'Tag 4' + assert_select 'optgroup[label="Other group"]' do + assert_select 'option[value="3"]', 'Tag 3' + assert_select 'option[value="4"]', 'Tag 4' end end end diff --git a/test/inputs/numeric_input_test.rb b/test/inputs/numeric_input_test.rb index f3947fc0..ead65ae6 100644 --- a/test/inputs/numeric_input_test.rb +++ b/test/inputs/numeric_input_test.rb @@ -32,7 +32,7 @@ class NumericInputTest < ActionView::TestCase assert_no_select 'input[min]' with_input_for @other_validating_user, :age, :integer - assert_select 'input[min=18]' + assert_select 'input[min="18"]' end test 'input infers min value from integer attributes with greater than validation using symbol' do @@ -40,15 +40,15 @@ class NumericInputTest < ActionView::TestCase assert_no_select 'input[min]' with_input_for @validating_user, :amount, :integer - assert_select 'input[min=11]' + assert_select 'input[min="11"]' end test 'input infers min value from integer attributes with greater than or equal to validation using symbol' do with_input_for @validating_user, :attempts, :float - assert_select 'input[min=1]' + assert_select 'input[min="1"]' with_input_for @validating_user, :attempts, :integer - assert_select 'input[min=1]' + assert_select 'input[min="1"]' end test 'input infers min value from integer attributes with greater than validation using proc' do @@ -56,15 +56,15 @@ class NumericInputTest < ActionView::TestCase assert_no_select 'input[min]' with_input_for @other_validating_user, :amount, :integer - assert_select 'input[min=20]' + assert_select 'input[min="20"]' end test 'input infers min value from integer attributes with greater than or equal to validation using proc' do with_input_for @other_validating_user, :attempts, :float - assert_select 'input[min=19]' + assert_select 'input[min="19"]' with_input_for @other_validating_user, :attempts, :integer - assert_select 'input[min=19]' + assert_select 'input[min="19"]' end test 'input infers max value from attributes with less than validation' do @@ -72,7 +72,7 @@ class NumericInputTest < ActionView::TestCase assert_no_select 'input[max]' with_input_for @other_validating_user, :age, :integer - assert_select 'input[max=99]' + assert_select 'input[max="99"]' end test 'input infers max value from attributes with less than validation using symbol' do @@ -80,15 +80,15 @@ class NumericInputTest < ActionView::TestCase assert_no_select 'input[max]' with_input_for @validating_user, :amount, :integer - assert_select 'input[max=99]' + assert_select 'input[max="99"]' end test 'input infers max value from attributes with less than or equal to validation using symbol' do with_input_for @validating_user, :attempts, :float - assert_select 'input[max=100]' + assert_select 'input[max="100"]' with_input_for @validating_user, :attempts, :integer - assert_select 'input[max=100]' + assert_select 'input[max="100"]' end test 'input infers max value from attributes with less than validation using proc' do @@ -96,15 +96,15 @@ class NumericInputTest < ActionView::TestCase assert_no_select 'input[max]' with_input_for @other_validating_user, :amount, :integer - assert_select 'input[max=118]' + assert_select 'input[max="118"]' end test 'input infers max value from attributes with less than or equal to validation using proc' do with_input_for @other_validating_user, :attempts, :float - assert_select 'input[max=119]' + assert_select 'input[max="119"]' with_input_for @other_validating_user, :attempts, :integer - assert_select 'input[max=119]' + assert_select 'input[max="119"]' end test 'input has step value of any except for integer attribute' do @@ -112,7 +112,7 @@ class NumericInputTest < ActionView::TestCase assert_select 'input[step="any"]' with_input_for @validating_user, :age, :integer - assert_select 'input[step=1]' + assert_select 'input[step="1"]' end test 'numeric input does not generate placeholder by default' do @@ -122,7 +122,7 @@ class NumericInputTest < ActionView::TestCase test 'numeric input accepts the placeholder option' do with_input_for @user, :age, :integer, placeholder: 'Put in your age' - assert_select 'input.integer[placeholder=Put in your age]' + assert_select 'input.integer[placeholder="Put in your age"]' end test 'numeric input uses i18n to translate placeholder text' do @@ -130,7 +130,7 @@ class NumericInputTest < ActionView::TestCase age: 'Age goes here' } } }) do with_input_for @user, :age, :integer - assert_select 'input.integer[placeholder=Age goes here]' + assert_select 'input.integer[placeholder="Age goes here"]' end end @@ -156,12 +156,12 @@ class NumericInputTest < ActionView::TestCase [:integer, :float, :decimal].each do |type| test "#{type} input infers min value from attributes with greater than or equal validation" do with_input_for @validating_user, :age, type - assert_select 'input[min=18]' + assert_select 'input[min="18"]' end test "#{type} input infers the max value from attributes with less than or equal to validation" do with_input_for @validating_user, :age, type - assert_select 'input[max=99]' + assert_select 'input[max="99"]' end end diff --git a/test/inputs/priority_input_test.rb b/test/inputs/priority_input_test.rb index 69884a27..3b8bbeb1 100644 --- a/test/inputs/priority_input_test.rb +++ b/test/inputs/priority_input_test.rb @@ -6,13 +6,13 @@ class PriorityInputTest < ActionView::TestCase with_input_for @user, :country, :country assert_select 'select#user_country' assert_select 'select option[value=Brazil]', 'Brazil' - assert_no_select 'select option[value=][disabled=disabled]' + assert_no_select 'select option[value=""][disabled=disabled]' end test 'input generates a country select with SimpleForm default' do swap SimpleForm, country_priority: [ 'Brazil' ] do with_input_for @user, :country, :country - assert_select 'select option[value=][disabled=disabled]' + assert_select 'select option[value=""][disabled=disabled]' end end @@ -20,19 +20,19 @@ class PriorityInputTest < ActionView::TestCase with_input_for @user, :time_zone, :time_zone assert_select 'select#user_time_zone' assert_select 'select option[value=Brasilia]', '(GMT-03:00) Brasilia' - assert_no_select 'select option[value=][disabled=disabled]' + assert_no_select 'select option[value=""][disabled=disabled]' end test 'input generates a time zone select field with default' do with_input_for @user, :time_zone, :time_zone, default: 'Brasilia' assert_select 'select option[value=Brasilia][selected=selected]' - assert_no_select 'select option[value=]' + assert_no_select 'select option[value=""]' end test 'input generates a time zone select using options priority' do with_input_for @user, :time_zone, :time_zone, priority: /Brasilia/ - assert_select 'select option[value=][disabled=disabled]' - assert_no_select 'select option[value=]', /^$/ + assert_select 'select option[value=""][disabled=disabled]' + assert_no_select 'select option[value=""]', /^$/ end test 'priority input does not generate invalid required html attribute' do diff --git a/test/inputs/string_input_test.rb b/test/inputs/string_input_test.rb index faaaec9a..7ca14815 100644 --- a/test/inputs/string_input_test.rb +++ b/test/inputs/string_input_test.rb @@ -4,7 +4,7 @@ require 'test_helper' class StringInputTest < ActionView::TestCase test 'input maps text field to string attribute' do with_input_for @user, :name, :string - assert_select "input#user_name[type=text][name='user[name]'][value=New in SimpleForm!]" + assert_select 'input#user_name[type=text][name="user[name]"][value="New in SimpleForm!"]' end test 'input generates a password field for password attributes' do @@ -14,7 +14,7 @@ class StringInputTest < ActionView::TestCase test 'input gets maxlength from column definition for string attributes' do with_input_for @user, :name, :string - assert_select 'input.string[maxlength=100]' + assert_select 'input.string[maxlength="100"]' end test 'input does not get maxlength from column without size definition for string attributes' do @@ -24,12 +24,12 @@ class StringInputTest < ActionView::TestCase test 'input gets maxlength from column definition for password attributes' do with_input_for @user, :password, :password - assert_select 'input.password[type=password][maxlength=100]' + assert_select 'input.password[type=password][maxlength="100"]' end test 'input infers maxlength column definition from validation when present' do with_input_for @validating_user, :name, :string - assert_select 'input.string[maxlength=25]' + assert_select 'input.string[maxlength="25"]' end test 'input does not get maxlength from validation when tokenizer present' do @@ -39,13 +39,13 @@ class StringInputTest < ActionView::TestCase test 'input gets maxlength from validation when :is option present' do with_input_for @validating_user, :home_picture, :string - assert_select 'input.string[maxlength=12]' + assert_select 'input.string[maxlength="12"]' end test 'input maxlength is the column limit plus one to make room for decimal point' do with_input_for @user, :credit_limit, :string - assert_select "input.string[maxlength=16]" + assert_select 'input.string[maxlength="16"]' end test 'input does not generate placeholder by default' do @@ -55,12 +55,12 @@ class StringInputTest < ActionView::TestCase test 'input accepts the placeholder option' do with_input_for @user, :name, :string, placeholder: 'Put in some text' - assert_select 'input.string[placeholder=Put in some text]' + assert_select 'input.string[placeholder="Put in some text"]' end test 'input generates a password field for password attributes that accept placeholder' do with_input_for @user, :password, :password, placeholder: 'Password Confirmation' - assert_select 'input[type=password].password[placeholder=Password Confirmation]#user_password' + assert_select 'input[type=password].password[placeholder="Password Confirmation"]#user_password' end test 'input does not infer pattern from attributes by default' do @@ -100,7 +100,7 @@ class StringInputTest < ActionView::TestCase name: 'Name goes here' } } }) do with_input_for @user, :name, :string - assert_select 'input.string[placeholder=Name goes here]' + assert_select 'input.string[placeholder="Name goes here"]' end end @@ -110,7 +110,7 @@ class StringInputTest < ActionView::TestCase } } }) do swap SimpleForm, i18n_scope: :my_scope do with_input_for @user, :name, :string - assert_select 'input.string[placeholder=Name goes here]' + assert_select 'input.string[placeholder="Name goes here"]' end end end diff --git a/test/inputs/text_input_test.rb b/test/inputs/text_input_test.rb index 48d6d3d2..b013fda4 100644 --- a/test/inputs/text_input_test.rb +++ b/test/inputs/text_input_test.rb @@ -9,16 +9,16 @@ class TextInputTest < ActionView::TestCase test 'input generates a text area for text attributes that accept placeholder' do with_input_for @user, :description, :text, placeholder: 'Put in some text' - assert_select 'textarea.text[placeholder=Put in some text]' + assert_select 'textarea.text[placeholder="Put in some text"]' end test 'input gets maxlength from column definition for text attributes' do with_input_for @user, :description, :text - assert_select 'textarea.text[maxlength=200]' + assert_select 'textarea.text[maxlength="200"]' end test 'input infers maxlength column definition from validation when present for text attributes' do with_input_for @validating_user, :description, :text - assert_select 'textarea.text[maxlength=50]' + assert_select 'textarea.text[maxlength="50"]' end end