Rspec - redirect_to与正则表达式匹配的路径

 jajajaja幸福_348 发布于 2023-02-09 11:29

我在Rspec中有以下内容

response.should redirect_to %r{\A/my_settings/mysub_path/}

我收到以下错误

NoMethodError: undefined method `model_name' for Regexp:Class

我只需要匹配包含my_settings/mysub_path的路径的一部分.如何在rspec中实现这一目标?

1 个回答
  • 要检查正则表达式的重定向,请在response.location上执行字符串匹配,如下所示:

    expect(response.location).to match('your_expected_location.com')
    

    2023-02-09 11:32 回答
撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有