Search code examples
rubyrspeccapybaracase-insensitive

Case insensitive Rspec match


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')

Solution

  • 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)