简体   繁体   English

运行RSpec测试时没有“ .includes”红宝石方法

[英]No “.includes?” ruby method when running RSpec Test

I've recently got into RSpec and i'm writing some tests for my code, one of things my code has is a section where it starts by going if category.name.includes?(matcher) and then it does something, running this code in production is fine however whenever i'm testing that piece of code with RSpec I get the following error: 最近,我进入了RSpec,我正在为我的代码编写一些测试,我的代码包含的内容之一是其中的一个部分,首先检查if category.name.includes?(matcher) ,然后执行一些操作,然后运行此代码生产中的代码很好,但是每当我使用RSpec测试该代码段时,都会出现以下错误:

undefined method 'includes?' for "category21":String

To clear some things up, my factories do clearly define the categories name, i'm mainly wondering if I need to include some form of library to get it to play nicely? 为了弄清楚一些事情,我的工厂确实明确定义了类别名称,我主要是想知道是否需要包括某种形式的库才能使其正常运行?

Thanks, Grant 谢谢,格兰特

You should use include? 您应该使用include吗? , not includes? ,不includes? .

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM