Closed sanfrecce-osaka closed 1 year ago
Same problem with psych 3.3.3. #389 works for me :)
Please fix this, I spent about 2 hours debugging to find this issue.
@sanfrecce-osaka @joshuacronemeyer #389 has been merged, so it looks like we can close this issue.
Steps to reproduce
Under the following conditions,
run the following.
This is the expected result.
Next, run the following.
I was expecting that value is
Date
as well, but it turned out to beString
.Expected behavior
Value is
Date
.Actual behavior
Value is
String
.Reason
Since
psych
4.0.5,Psych::ScalarScanner#tokenize
passesDate::GREGORIAN
as the third argument ofDate.strptime
.cf. https://github.com/ruby/psych/pull/573
However, when using
timecop
,Date.strptime_with_mock_date
(This is an alias ofDate.strptime
) only allowsDate::ITALY
as the third argument.cf. https://github.com/travisjeffery/timecop/blob/v0.9.5/lib/timecop/time_extensions.rb#L47-L51
So
ArgumentError
is raised andPsych::ScalarScanner#tokenize
returnsString
.cf. https://github.com/ruby/psych/blob/v4.0.5/lib/psych/scalar_scanner.rb#L63-L69