Skip to content

Fix accidental double spaces in locale data#3306

Open
benoitcalin wants to merge 1 commit into
faker-ruby:mainfrom
benoitcalin:fix/collapse-double-spaces-locale-data
Open

Fix accidental double spaces in locale data#3306
benoitcalin wants to merge 1 commit into
faker-ruby:mainfrom
benoitcalin:fix/collapse-double-spaces-locale-data

Conversation

@benoitcalin

Copy link
Copy Markdown

Fix accidental double spaces in locale data

Problem

Several locale entries contain runs of consecutive spaces between words, e.g. Leo Hamon and Louis Bleriot in fr/address.yml. These flow straight into generated values (Faker::Address.street_name, full_address, …).

Browsers collapse consecutive whitespace when rendering HTML, so any downstream test that asserts exact text against a generated address becomes flaky: the expected string carries a double space that the rendered page no longer has. This bit us on a Capybara feature spec (expect(page).to have_content(record.address)) roughly 0.5% of the time on the :fr locale, with no way to fix it cleanly on the consumer side.

Changes

Collapsed the accidental double/triple spaces in these entries:

  • fr/address.ymlstreet_suffix: Leo Hamon
  • sk.ymladdress.street: Búdkova cesta
  • en/opera.yml — 9 Rossini titles (… ossia …, Elisabetta regina …, Ugo re d'Italia)
  • en/dumb_and_dumber.yml — one quote (LA LA LA LA LA LA! LLOYD!)
  • en/restaurant.ymldescription (citizen to provide) and review (neglected. Seen)

Added test/test_locale_data_integrity.rb: a guard that walks every locale YAML and fails on any string value containing consecutive spaces between words, so this class of typo can't creep back in across locales.

Intentionally left untouched: en/crypto_coin.yml, whose entries use aligned spaces inside a comma-separated string that Faker::CryptoCoin splits and strips before returning. Those spaces never reach generated output, so the test explicitly excludes that key.

Console output

Faker::Base.translate for the affected keys, after the fix (no entry contains consecutive spaces anymore), and crypto_coin still returning stripped values:

address.street_suffix (fr): no double-space entries
address.street (sk): no double-space entries
opera.italian.by_gioacchino_rossini (en): no double-space entries
dumb_and_dumber.quotes (en): no double-space entries
restaurant.description (en): no double-space entries
restaurant.review (en): no double-space entries
crypto_coin still aligned+stripped: ["NEO", "NEO", "https://i.imgur.com/BmtVrJi.png"]

The new test fails on main (14 offending entries reported) and passes with the data fixes applied.

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.

1 participant