Skip to content

Run the Naruto and Indian GST tests - #3327

Open
dpep wants to merge 1 commit into
faker-ruby:mainfrom
dpep:run-never-run-tests
Open

dpep wants to merge 1 commit into
faker-ruby:mainfrom
dpep:run-never-run-tests

Conversation

@dpep

@dpep dpep commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

Motivation / Background

This Pull Request has been created because two tests are named text_ instead of test_, so neither has ever run:

Turning the GST test back on exposed two bugs it would have caught:

  • Its regex allowed state codes 00–37, but indian_gst_number generates 02–38 and 98, as documented. The regex now matches what's documented.
  • About 10% of generated numbers were 14 characters, not 15 (e.g. 13AGZHR303L5ZS). g_.int(length: 4, ranges: [0..9999]) ignores length when ranges is given (PositionalGenerator::Int), so values below 1000 weren't zero-padded. It now uses g_.int(length: 4) (1000–9999). That drops the 0001–0999 range real PANs allow, in exchange for always being 15 characters. Happy to pad instead if you'd rather keep the full range.

Additional information

5,000 generated GSTINs all match the updated regex and are all 15 characters.

This depends on #3326. With these tests running, the suite's fixed random sequence (the Random.new(42) that test_determinism leaves set) shifts and lands on a duplicate first name in test_nested_json_length. With #3326 merged in, rake test passes (2185 tests), and rubocop is clean.

Checklist

  • This Pull Request is related to one change. Changes that are unrelated should be opened in separate PRs.
  • Commit message has a detailed description of what changed and why. If this PR fixes a related issue include it in the commit message. Ex: [Fix #issue-number]
  • Tests are added or updated if you fix a bug, refactor something, or add a feature.
  • Tests and Rubocop are passing before submitting your proposed changes.

Found with trekr

Both were named text_ instead of test_, so neither has ever run:
- text_faker_naruto.rb is outside the test/**/test*.rb glob (since
  cb72197).
- TestFakerCompany#text_indian_gst_number isn't picked up by Test::Unit
  (since 205bc52).

Renaming the GST test exposed two problems it would have caught:
- its regex only allowed state codes 00-37, while indian_gst_number
  generates 02-38 and 98, as documented;
- ~10% of generated numbers were 14 characters: `int(length: 4,
  ranges: [0..9999])` ignores length when ranges are given, so values
  below 1000 weren't zero-padded. Generate 4 digits instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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