不区分大小写的Rspec匹配 [英] Case insensitive Rspec match

查看:79
本文介绍了不区分大小写的Rspec匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写Capybara测试,并使用Rspec进行断言。我的测试失败了,因为正在应用CSS样式,导致文本全部大写。我该如何重写它,使它成为不区分大小写的断言?

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


推荐答案

这里是对phoet解决方案的改进:

Here's improving on phoet's solution:

page.body.should match(%r{#{string}}i)

不幸的是,此处突出显示的语法并没有做到太多公正(在Sublime Text中看起来很好)

Unfortunately the syntax highlighting here isn't doing it much justice (it looks perfectly fine in Sublime Text)

这篇关于不区分大小写的Rspec匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆