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

bug: sport generator sometimes returns an array result #2608

Closed
thdaraujo opened this issue Oct 31, 2022 · 2 comments
Closed

bug: sport generator sometimes returns an array result #2608

thdaraujo opened this issue Oct 31, 2022 · 2 comments

Comments

@thdaraujo
Copy link
Contributor

Describe the bug

There seems to be a bug on the sports generator.

As reported here, there is a test that seems flaky at first.
The code runs this generator: ``Faker::Sport.sport(include_ancient: true)`, and sometimes raises the following error:

Error: test_sport_with_ancient_allowed(TestFakerSports): TypeError: no implicit conversion of Array into String
/home/runner/work/faker/faker/test/faker/sports/test_faker_sports.rb:15:in `test_sport_with_ancient_allowed'
     12:   end
     13: 
     14:   def test_sport_with_ancient_allowed
  => 15:     assert_match(/\w+/, @tester.sport(include_ancient: true))
     16:   end
     17: 
     18:   def test_sport_with_unusual_allowed

To Reproduce

Faker::VERSION 
=> "2.23.0"

Use the reproduction script below to reproduce the issue:

require 'faker'

1_000.times do |i|
   sport = Faker::Sport.sport(include_ancient: true)
   if !sport.is_a?(String)
     raise "sport should be a string: #{sport.inspect}"
   end
end

# => sport should be a string: ["Boxing", "Chariot racing", "Discus", "Horse racing", "Long jump", "Pankration", "Pentathlon", "Running", "Wrestling"] (RuntimeError)

Expected behavior

Generator should return a string

@si-lens
Copy link
Contributor

si-lens commented Nov 3, 2022

I know what the problem is. I can gladly fix it.

@stefannibrasil
Copy link
Contributor

Fixed by #2616. Thank you @si-lens !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants