I am trying to check for images src in a HTML img tag using following code
extension.end_with?(/[.jpg|.gif|.png|.jpeg]/).should eq(true)
where
extension = “teaser_image610x450.jpg”
I also tried
extension.end_with?(/[.]jpg|gif|png|jpeg/).should eq(true)
In both cases I am getting FALSE.
What is wrong with above code ?
You can use the following form:
Or, something like this:
I never saw this method being used with a regex before.