Rspec测试失败,因为对于Date类实例,未定义方法”in”。

huangapple go评论61阅读模式
英文:

Rspec test failing due to the undefined method "in" for a Date class instance

问题

I'm attempting to test a method that uses the at method on a Date class instance.

ex: start_at = day.at(ordering_range.open_time)

and I get this error:

eval error: undefined method `at' for 2023-02-07 20:10:54.835826 -0500:Date

Event though at is instance method of Date outside of rspec

Is this an issue with rspec? Is it possible to test?

英文:

I'm attempting to test a method that uses the at method on a Date class instance.

ex: start_at = day.at(ordering_range.open_time)

and I get this error:

eval error: undefined method `at' for 2023-02-07 20:10:54.835826 -0500:Date

Event though at is instance method of Date outside of rspec

Is this an issue with rspec? Is it possible to test?

答案1

得分: 2

at 是一个类方法,通常用于将自纪元以来的秒数转换为一个时间对象。

Time.at(1)  # 1969-12-31 16:00:01 -0800 
英文:

at is a class method, it's generally used to convert from number of seconds since the epoch to a Time object.

Time.at(1)  # 1969-12-31 16:00:01 -0800 

huangapple
  • 本文由 发表于 2023年2月8日 09:26:58
  • 转载请务必保留本文链接:https://go.coder-hub.com/75380566.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定