From 4d65507cbbd5dfc0c0ca776570e272e20df6054c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Wed, 27 May 2020 18:49:31 +0200 Subject: [PATCH] Check for exact text in `have_ckeditor` If we don't use the `exact` option, tests will pass even if filling in CKEditor adds the content twice or adds the new content to the existing content, which has actually happened and has gone mostly unnoticed while testing several ways to fill in CKEditor with Capybara (particularly, when using Capybara's `send_keys` method). The problem was detected by just one test, which checked the original content wasn't present anymore after updating a record. --- spec/support/matchers/have_ckeditor.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/support/matchers/have_ckeditor.rb b/spec/support/matchers/have_ckeditor.rb index 8072ad511..e25df236d 100644 --- a/spec/support/matchers/have_ckeditor.rb +++ b/spec/support/matchers/have_ckeditor.rb @@ -15,7 +15,7 @@ RSpec::Matchers.define :have_ckeditor do |label, with:| return false unless has_ckeditor? page.within(ckeditor_id) do - within_frame(0) { has_content?(with) } + within_frame(0) { has_content?(with, exact: true) } end end