From b626ec1cd734270307f2eb14cb86cdecb374c922 Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Wed, 15 Nov 2023 10:13:24 +1100 Subject: [PATCH] Further reduce branching This is much easier to read. --- .../system/consumer/shopping/products_spec.rb | 23 ++++++++----------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/spec/system/consumer/shopping/products_spec.rb b/spec/system/consumer/shopping/products_spec.rb index 4d5f41ab78..ef4fef65f3 100644 --- a/spec/system/consumer/shopping/products_spec.rb +++ b/spec/system/consumer/shopping/products_spec.rb @@ -89,8 +89,10 @@ describe "As a consumer I want to view products" do expect(html).to include product.description expect(page).to have_content "..." end - expect_product_description_html_to_be_displayed(product, product.description, nil, - href: true) + within_product_modal(product) do + expect(html).to include product.description + expect(find_link('external site')[:target]).to eq('_blank') + end end it "does not show unsecure HTML" do @@ -104,9 +106,10 @@ describe "As a consumer I want to view products" do expect(html).to include "

Safe

" expect(html).not_to include "" end - expect_product_description_html_to_be_displayed( - product, "

Safe

", "" - ) + within_product_modal(product) do + expect(html).to include "

Safe

" + expect(html).not_to include "" + end end end @@ -153,16 +156,10 @@ describe "As a consumer I want to view products" do end end - def expect_product_description_html_to_be_displayed(product, html, not_include = nil, - href: false) - # check in product description modal + def within_product_modal(product, &) click_link product.name modal_should_be_open_for product - within(".reveal-modal") do - expect(find_link('external site')[:target]).to eq('_blank') if href - expect(html).to include(html) - expect(html).not_to include(not_include) if not_include - end + within(".reveal-modal", &) end def within_product_description(product, &)