Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing the CI failure by fixing the infinite loop in Commerce #1971

Merged
merged 2 commits into from
May 14, 2020

Conversation

amatsuda
Copy link
Contributor

@amatsuda amatsuda commented May 9, 2020

It seems that current faker master is broken https://travis-ci.org/github/faker-ruby/faker/builds since 7034961.
What's happening here is that the ko locale data provides only one commerce.department entry where some tests e.g.

assert_match ' & ', @tester.department(max: 2, fixed_amount: true)
expects more than two commerce.department entries to exist, and because this loop never ends until it successfully fetches the given number of categories, it results in an infinite loop.

This is rather a code bug than a data inadequacy. No code should cause such an infinite loop regardless of given data.

This patch firstly extends the existing sample method to take an argument in the same manner as Ruby's Array#sample.
Then now we can simplify the code by using this new sample with number instead of fetching multiple times inside the loop.

@stympy stympy merged commit df65207 into faker-ruby:master May 14, 2020
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