I'm writing a Capybara test and using Rspec for the assertions. My test is failing because there is a CSS style being applied that is causing the text to be in all caps. How can I rewrite this so that it is a case insensitive assertion?
"ALL CAPS".should include('All Caps')
Here's improving on phoet's solution:
page.body.should match(%r{#{string}}i)
Unfortunately the syntax highlighting here isn't doing it much justice (it looks perfectly fine in Sublime Text)
I only run into this issue when:
Using poltergeist driver. (I don't know if this also happens with other drivers)
Inspecting page
, not page.body
for expectations: expect(page).to ...
So, If I do expect(page.body).to ...
it just works and solved the issue.
how about using a regex to do this?
"ALL CAPS".should match(/#{Regexp.escape('All Caps')}/i)
How about downcasing both ends of the assertion?
"ALL CAPS".downcase.should include('All Caps'.downcase)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With