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 trying to test a service which provides calculated deadlines for records. My test goes something like this:
require'rails_helper'RSpec.describeCalculateDeadline,type: :modeldodescribe'for priority certificates'dolet(:certificate){create:certificate,service_level: 'priority'}it'returns 3 business days'doexpect(CalculateDeadline.callcertificate).toeq3.business_daysendendend
Of course, this fails miserably since there are no comparison methods provided and the two times are separate instances of BusinessTime::BusinessDays and as such not identical.
Can we add an equality evaluation method. If not, please explain how else I should test my code without either creating two Time instances to compare, or poking about in the instance with something like 3.business_days.instance_variable_get('@days').
The text was updated successfully, but these errors were encountered:
pacso
changed the title
Basic comparison and manipulation methods
Basic comparison of business times
Oct 9, 2014
Interesting use... I always considered the objects returned by something like "3.business_days" to be throwaway; just someplace to hang the math related to the integer and time. I like this use case though, and fixing this should be as simple as implementing the spaceship operator on BusinessHours and BusinessDays and delegating to the integer they wrap.
That's what I thought, however having recently done some work on another gem which was eventually discarded by the maintainer I figured I'd make sure something like this would be wanted prior to wasting any more time.
I'm happy to put something together at the weekend and send you a pull request.
I am trying to test a service which provides calculated deadlines for records. My test goes something like this:
Of course, this fails miserably since there are no comparison methods provided and the two times are separate instances of
BusinessTime::BusinessDays
and as such not identical.Can we add an equality evaluation method. If not, please explain how else I should test my code without either creating two
Time
instances to compare, or poking about in the instance with something like3.business_days.instance_variable_get('@days')
.The text was updated successfully, but these errors were encountered: