diff --git a/spec/features/admin/translatable_spec.rb b/spec/features/admin/translatable_spec.rb index 9a9b76d98..c40919d81 100644 --- a/spec/features/admin/translatable_spec.rb +++ b/spec/features/admin/translatable_spec.rb @@ -55,15 +55,15 @@ describe "Admin edit translatable records" do visit path - within_frame(0) { expect(page).to have_content "Content in English" } + expect(page).to have_ckeditor "Content", with: "Content in English" select "Español", from: :select_language - within_frame(0) { expect(page).to have_content "Contenido en español" } + expect(page).to have_ckeditor "Content", with: "Contenido en español" select "Français", from: :select_language - within_frame(0) { expect(page).to have_content "Contenu en Français" } + expect(page).to have_ckeditor "Content", with: "Contenu en Français" end end @@ -155,7 +155,7 @@ describe "Admin edit translatable records" do select "Français", from: :select_language - within_frame(0) { expect(page.text).to be_empty } + expect(page). to have_ckeditor "Description", with: "" end end @@ -237,7 +237,7 @@ describe "Admin edit translatable records" do select("Español", from: "locale-switcher") expect(page).to have_field "Respuesta", with: "Respuesta corregida" - within_frame(0) { expect(page).to have_content "Descripción corregida" } + expect(page).to have_ckeditor "Descripción", with: "Descripción corregida" end end diff --git a/spec/features/translatable_spec.rb b/spec/features/translatable_spec.rb index a750947fa..d075f1487 100644 --- a/spec/features/translatable_spec.rb +++ b/spec/features/translatable_spec.rb @@ -212,7 +212,7 @@ describe "Public area translatable records" do select "Español", from: "locale-switcher" expect(page).to have_field "Título del debate", with: "Título corregido" - within_frame(0) { expect(page).to have_content "Texto corregido" } + expect(page).to have_ckeditor "Texto inicial del debate", with: "Texto corregido" end end diff --git a/spec/support/matchers/have_ckeditor.rb b/spec/support/matchers/have_ckeditor.rb new file mode 100644 index 000000000..7e23245ec --- /dev/null +++ b/spec/support/matchers/have_ckeditor.rb @@ -0,0 +1,19 @@ +RSpec::Matchers.define :have_ckeditor do |label, with:| + match do + return false unless has_css?(".ckeditor", text: label) + + page.within(".ckeditor", text: label) do + within_frame(0) { has_content?(with) } + end + end + + failure_message do + if has_css?(".ckeditor", text: label) + text = page.within(".ckeditor", text: label) { within_frame(0) { page.text } } + + "expected to find visible CKEditor '#{label}' with '#{with}', but had '#{text}'" + else + "expected to find visible CKEditor '#{label}' but there were no matches." + end + end +end