Soviet Ketchup Soviet Ketchup - 9 months ago 46
Ruby Question

Ruby rspec check string begins with certain values

I have a string that begins with a set start and then is filled to 252 characters by randomly generated letters. (237 random chars - so that the end length is 252 characters)

For the purpose of testing the string starts off with

and the rest is random capital letters.

How can I test that the characters are all capital letters
and that the string begins with

I have tried to use regex expressions to define this but I'm not too sure how to get them to work properly, and what I have tried so far seems not to be working.

EDIT: Clarity

expect(string).to match(/\ATESTDATAMENDNOW[A-Z]{237}\z/)

237 because 252 minus the length of "TESTDATAMENDNOW" is 237.