Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Assert if any of two strings are present

I have a webpage with two different strings depending on time of the day - "Good day" or "Good night".

Is there any way to do some sort of assert_content(my_string) that check if one of the two given strings is present?

It doesn't matter which one is present, just that one is.

like image 371
Fellow Stranger Avatar asked Nov 25 '25 09:11

Fellow Stranger


1 Answers

If using MiniTest then you can use assert_match:

assert_match /Good day|Good night/, string

If using RSpec then you can use match:

expect(string).to match /Good day|Good night/
like image 79
Sebastian Palma Avatar answered Nov 28 '25 03:11

Sebastian Palma



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!