From 914b58cb9d4f681b31c57a9eee9845143f5c977d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Mon, 17 Nov 2014 17:27:13 -0200 Subject: [PATCH] Assert the absent of tags not the escaped text Nokogiri doesn't escape the output --- test/form_builder/error_test.rb | 2 +- test/form_builder/hint_test.rb | 6 +++--- test/form_builder/label_test.rb | 2 +- test/form_builder/wrapper_test.rb | 4 ++-- test/inputs/boolean_input_test.rb | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/test/form_builder/error_test.rb b/test/form_builder/error_test.rb index f529540a..5dc0d40e 100644 --- a/test/form_builder/error_test.rb +++ b/test/form_builder/error_test.rb @@ -82,7 +82,7 @@ class ErrorTest < ActionView::TestCase test 'error escapes error prefix text' do with_error_for @user, :name, error_prefix: 'Name' - assert_select 'span.error', "<b>Name</b> can't be blank" + assert_no_select 'span.error b' end test 'error generates an error message with raw HTML tags' do diff --git a/test/form_builder/hint_test.rb b/test/form_builder/hint_test.rb index ca783676..68d5fb74 100644 --- a/test/form_builder/hint_test.rb +++ b/test/form_builder/hint_test.rb @@ -50,7 +50,7 @@ class HintTest < ActionView::TestCase test 'builder escapes hint text' do with_hint_for @user, :name, hint: '' - assert_select 'span.hint', "<script>alert(1337)</script>" + assert_no_select 'span.hint script' end # Without attribute name @@ -137,8 +137,8 @@ class HintTest < ActionView::TestCase test 'hint with custom wrappers works' do swap_wrapper do - with_hint_for @user, :name, hint: "can't be blank" - assert_select 'div.omg_hint', "can't be blank" + with_hint_for @user, :name, hint: "cannot be blank" + assert_select 'div.omg_hint', "cannot be blank" end end end diff --git a/test/form_builder/label_test.rb b/test/form_builder/label_test.rb index 4cf4bc8a..503bc8da 100644 --- a/test/form_builder/label_test.rb +++ b/test/form_builder/label_test.rb @@ -31,7 +31,7 @@ class LabelTest < ActionView::TestCase test 'builder escapes label text' do with_label_for @user, :name, label: '', required: false - assert_select 'label.string', "<script>alert(1337)</script>" + assert_no_select 'label.string script' end test 'builder does not escape label text if it is safe' do diff --git a/test/form_builder/wrapper_test.rb b/test/form_builder/wrapper_test.rb index fb023f53..379c312b 100644 --- a/test/form_builder/wrapper_test.rb +++ b/test/form_builder/wrapper_test.rb @@ -270,8 +270,8 @@ class WrapperTest < ActionView::TestCase test 'inline wrapper displays when there is content' do swap_wrapper :default, self.custom_wrapper_with_wrapped_optional_component do - with_form_for @user, :name, hint: "can't be blank" - assert_select 'section.custom_wrapper div.no_output_wrapper p.omg_hint', "can't be blank" + with_form_for @user, :name, hint: "cannot be blank" + assert_select 'section.custom_wrapper div.no_output_wrapper p.omg_hint', "cannot be blank" assert_select 'p.omg_hint' end end diff --git a/test/inputs/boolean_input_test.rb b/test/inputs/boolean_input_test.rb index c1a58fe9..af4488e5 100644 --- a/test/inputs/boolean_input_test.rb +++ b/test/inputs/boolean_input_test.rb @@ -57,7 +57,7 @@ class BooleanInputTest < ActionView::TestCase test 'input boolean with nested escapes :inline_label with HTML' do swap SimpleForm, boolean_style: :nested do with_input_for @user, :active, :boolean, inline_label: 'I am so inline.' - assert_select 'label.checkbox', text: ' <b>I am so inline.</b>' + assert_no_select 'label.checkbox b' end end