summaryrefslogtreecommitdiff
path: root/spec/support/shared_contexts/html_safe_shared_context.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/support/shared_contexts/html_safe_shared_context.rb')
-rw-r--r--spec/support/shared_contexts/html_safe_shared_context.rb23
1 files changed, 23 insertions, 0 deletions
diff --git a/spec/support/shared_contexts/html_safe_shared_context.rb b/spec/support/shared_contexts/html_safe_shared_context.rb
new file mode 100644
index 00000000000..9bdaea9fe64
--- /dev/null
+++ b/spec/support/shared_contexts/html_safe_shared_context.rb
@@ -0,0 +1,23 @@
+# frozen_string_literal: true
+
+RSpec.shared_context 'when rendered has no HTML escapes' do
+ # Check once per example if `rendered` contains HTML escapes.
+ let(:rendered) do |example|
+ super().tap do |rendered|
+ next if example.metadata[:skip_html_escaped_tags_check]
+
+ HtmlEscapedHelpers.ensure_no_html_escaped_tags!(rendered, example)
+ end
+ end
+end
+
+RSpec.shared_context 'when page has no HTML escapes' do
+ # Check once per example if `page` contains HTML escapes.
+ let(:page) do |example|
+ super().tap do |page|
+ next if example.metadata[:skip_html_escaped_tags_check]
+
+ HtmlEscapedHelpers.ensure_no_html_escaped_tags!(page.native.to_s, example)
+ end
+ end
+end