is there way in integration tests manipulate cookie's expiration date (as test if taken account properly). example, if cookies['user_id']
exists in test, manipulate this:
cookies['user_id'].expires = time.zone.now - 1.day
(this returns undefined method 'expires='
)
i'm using minitest in rails.
you can use timecop time travel in test:
def setup do_something_which_sets_cookie timecop.freeze(1.month.from_now) # or how ever long takes cookie expire end def teardown timecop.return end
this can nice approach if want test how application behaves after period of time without tying test implementation details.
otherwise need ensure cookie exists before setting expiry:
cookies['user_id'].expires = time.zone.now - 1.day if cookies['user_id']
Comments
Post a Comment