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
Would it be possible to change the implementation so the freeze/travel methods return the result of the passed in block, instead of current time? I think that would be more useful, because then you could do something like this:
user = Timecop.freeze(2.years.ago) { User.create!(:name => '...') }
Instead of this:
user = nil
Timecop.freeze(2.years.ago) do
user = User.create!(:name => '...')
end
I think that first line is necessary, because otherwise the user variable is lost when it comes out of block's scope.
The text was updated successfully, but these errors were encountered:
This is an interesting use case, one that I've never really used Timecop for. I'm not 100% sold on the change...I like the consistency of returning Time.now from all 3 functions (freeze, travel, return). Furthermore, you can invoke #freeze and #travel without passing a block.
Can you get away with using an instance variable (@user)? That will eliminate the need to define the variable prior to the method call.
It would be trivial to apply the change you're asking for, but I don't think I'm going to add it to the library. I know its not ideal, but it would be pretty simple to maintain your own fork. This library, though only versioned 0.3.0, is pretty mature. I don't foresee many changes to the codebase moving forward.
Hello,
Would it be possible to change the implementation so the freeze/travel methods return the result of the passed in block, instead of current time? I think that would be more useful, because then you could do something like this:
Instead of this:
I think that first line is necessary, because otherwise the
user
variable is lost when it comes out of block's scope.The text was updated successfully, but these errors were encountered: