The Wayback Machine - https://web.archive.org/web/20200609210003/https://github.com/faker-ruby/faker/issues/1482
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

Include a note in the docs that some Dune characters are parsable as dates #1482

Open
elena-vi opened this issue Nov 20, 2018 · 2 comments
Open
Assignees
Labels

Comments

@elena-vi
Copy link

@elena-vi elena-vi commented Nov 20, 2018

I was using faker in Faker::Dune.character in an rspec test as an invalid date string to test that an error get's thrown, but then discovered that Thufir Hawat is a parsable date. So maybe mention that in the Dune doc?

irb(main):096:0>   Date.parse('Thufir Hawat')
=> #<Date: 2018-11-22 ((2458445j,0s,0n),+0s,2299161j)>
@vbrazo vbrazo added the Suggestion label Nov 20, 2018
@vbrazo vbrazo changed the title Suggestion: Include a note in the docs that some Dune characters are parsable as dates Include a note in the docs that some Dune characters are parsable as dates Nov 20, 2018
@richardbulger
Copy link
Contributor

@richardbulger richardbulger commented Dec 14, 2018

I'd argue your test is wrong. Date.parse will just pick out any date it can from the string. In this case "Thu" returns the date for the nearest Thursday. Perhaps use strptime to specify the date format so it doesn't pick trip up on strings that happen to have bits it can parse:
irb(main):007:0> Date.strptime('Thufir Hawat', '%Y-%m-%d')
ArgumentError: invalid date

@elena-vi
Copy link
Author

@elena-vi elena-vi commented Dec 14, 2018

Oh agree, that test was most definitely not the best and since has been rewritten

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
3 participants
You can’t perform that action at this time.