You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am working with some code that is highly timezone dependent and am struggling to get Timecop to work for me here. I am using Ruby 3.2, and make use of the in: keyword argument in Time.new and Time.now
When using Timecop, the in keyword doesn't seem to be supported.
As you can see there, when using in: the time is no longer frozen.
Additionally, Time.now does not appear to support the in: keyword argument at all when using Timecop:
#Time.nowputsTime.now(in: "+04:00")#2024-09-24 17:56:42 +0400require'timecop'putsTime.now(in: "+04:00")# timecop-0.9.10/lib/timecop/time_extensions.rb:13:in `now_with_mock_time': wrong number of arguments (given 1, expected 0) (ArgumentError)
I see where Ruby 3.1 support was added in v0.9.4 to support these keywords but it seems like something is missing. It looks like the Timecop implementation of nowdoesn't accept any arguments and in new calls out to new_without_mock_time if there are keyword arguments, even if no positional arguments are passed.
The text was updated successfully, but these errors were encountered:
Hey there @mcfadden thanks for the bug report! You're right we have not implemented this new-ish feature of Ruby. Are you willing to create a PR? I'm the maintainer for Timecop. I consider this a high-priority issue and would be happy to support anyone who wants to implement this. If not we'll leave this issue open here for a bit and see if anyone in the community wants to take it on.
I am working with some code that is highly timezone dependent and am struggling to get Timecop to work for me here. I am using Ruby 3.2, and make use of the
in:
keyword argument inTime.new
andTime.now
When using Timecop, the
in
keyword doesn't seem to be supported.As you can see there, when using
in:
the time is no longer frozen.Additionally,
Time.now
does not appear to support thein:
keyword argument at all when using Timecop:I see where Ruby 3.1 support was added in v0.9.4 to support these keywords but it seems like something is missing. It looks like the Timecop implementation of
now
doesn't accept any arguments and innew
calls out tonew_without_mock_time
if there are keyword arguments, even if no positional arguments are passed.The text was updated successfully, but these errors were encountered: