From d7060a8d666f32b54adf41c3580393778240502a Mon Sep 17 00:00:00 2001 From: Morgan Roderick Date: Mon, 29 Jun 2026 17:00:26 +0200 Subject: [PATCH] fix: align expected HTML output with html_escape in address presenter spec The test constructs an expected string from Faker-generated city names, which can contain apostrophes (e.g. O'Connerstad). ERB::Util.html_escape escapes ' to ', but the expected value used raw characters, making the test pass or fail depending on which random city Faker returns. Wrap each component in ERB::Util.html_escape to match the presenter's behaviour, eliminating the flake. --- spec/presenters/address_presenter_spec.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spec/presenters/address_presenter_spec.rb b/spec/presenters/address_presenter_spec.rb index 01d45ca4a..67a08fe69 100644 --- a/spec/presenters/address_presenter_spec.rb +++ b/spec/presenters/address_presenter_spec.rb @@ -4,7 +4,8 @@ describe '#to_html' do it 'returns the address in HTML with lines separated with
tags' do - html_address = "#{address.flat}
#{address.street}
#{address.city}, #{address.postal_code}" + escape = ERB::Util.method(:html_escape) + html_address = "#{escape.call(address.flat)}
#{escape.call(address.street)}
#{escape.call(address.city)}, #{escape.call(address.postal_code)}" expect(presenter.to_html).to eq(html_address) end