I have a test where a reference number is generated after a successful transaction. Within this reference number is a timestamp of (hhmmss). This timestamp is captured at the time the user presses submit, not when the confirmation page appears with the reference number visible. For this reason, I can't use Time.now as it will always be wrong.
What I would like to do (if possible) is create a confirmation test where I look within the reference number and can confirm that the timestap is between x and y, with y being x - 20 seconds (to allow for the confirmation page to appear).
The confirmation message with reference is as follows:
"Your transaction reference number is: 0 16123 #{timestamp} A1"
The reference number appears in the middle of a sentence so I'd like to be along the lines of:
expect('location-of-text').to have_text "Your transaction reference number is: 0 1612 {timestamp_range_here} A1"
I'm not sure if it's possible to do what I need.
Any help for a solution would be great