Skip to content

fix: escape venue/sponsor names with apostrophes in CSS selectors#2707

Merged
mroderick merged 2 commits into
masterfrom
fix/event-card-flake
Jul 15, 2026
Merged

fix: escape venue/sponsor names with apostrophes in CSS selectors#2707
mroderick merged 2 commits into
masterfrom
fix/event-card-flake

Conversation

@mroderick

@mroderick mroderick commented Jul 15, 2026

Copy link
Copy Markdown
Collaborator

What

Fix a test flake in EventCardComponent where Faker-generated venue or sponsor names with apostrophes (e.g. Simon O'Connell) break CSS attribute selectors using single quotes: img[alt='Simon O'Connell'].

Root cause

The CSS selector have_css("img[alt='#{name}'"]) uses single-quote delimiters for the attribute value. An apostrophe in the name closes the string early, producing a Nokogiri::CSS::SyntaxError.

Fix

Switch to double-quoted CSS attribute selectors using Ruby %(...) literal syntax: have_css(%(img[alt="#{name}"])). Double quotes handle apostrophes in values without escaping.

Applies to both occurrences of this pattern in the spec (meeting venue image, sponsor logo image).

CI context

Flake observed in PR #2705 (Group 3, seed 3843): EventCardComponent with a meeting renders venue image for meetings

Testing

spec/components/event_card_component_spec.rb — 10 examples, 0 failures

Faker-generated venue and sponsor names can contain apostrophes (e.g.
"Simon O'Connell"), which break single-quoted CSS attribute selectors
like `img[alt='...']`. This causes a Nokogiri::CSS::SyntaxError.

Switch to double-quoted CSS attribute selectors via Ruby %(...) literal
syntax, which handles apostrophes without escaping.
@mroderick mroderick marked this pull request as ready for review July 15, 2026 05:51
@mroderick mroderick enabled auto-merge July 15, 2026 15:39
@mroderick mroderick merged commit 6faa731 into master Jul 15, 2026
8 checks passed
@mroderick mroderick deleted the fix/event-card-flake branch July 15, 2026 15:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants